Students will understand that a list in Python is a container that can hold multiple data values. They will learn how to create a list using brackets [ ], separate items with commas, and write simple list expressions.
So far, our programs could only store one value at a time — a single name, one amount of money, or one score. But what if we want to keep a whole class’s scores, a week’s spending record, or a list of shopping items? One variable isn’t enough. That’s when we use a List, which works like a big box that can hold many items. A list lets us store multiple pieces of data together and access each one by its position, called an index.
Syntax Explanation:
A list is a group of data items enclosed in [ ].
Each element is separated by a comma.
Example:
fruits = ["apple", "banana", "cherry"]
Key Points:
fruits[0]Example A: Creating and Accessing Lists
fruits = ["apple", "banana", "cherry"]
print(fruits)
print(fruits[0])
print(fruits[1])
print(fruits[2])
Output example A:
['apple', 'banana', 'cherry']
apple
banana
cherry
Example B: Mixed Data Types
info = ["Tom", 12, 4.5, True]
print(info)
Output example B:
['Tom', 12, 4.5, True]
A list is one of the most useful containers in Python. It allows us to manage multiple pieces of information efficiently, supporting reading, modifying, and extending data. Understanding indices is crucial because it forms the foundation for loops and data processing in future lessons.