Lists
This lesson will introduce lists in Python and focus on how to use them.
We'll cover the following
Grouping items together
Until now we have learned that a variable can only hold a single item. But there are many ways to hold multiple values and refer to all of them by a single variable in Python, and the most popular is a list. A list can hold multiple values at the same time. These values could belong to any data type.
Lists are mostly used to store similar kinds of information. For example, if we want to store the marks of 50 students of a class, we would not want to make 50 separate variables. Instead, we hold them in a list.
To make a list we need to enclose all items separated by commas in []
and assign them to a variable.
Get hands-on with 1400+ tech skills courses.