A list is an ordered set of objects in Python.
Suppose we want to make a list of the heights of students in a class:
In Python, we can create a variable called
heights to store these numbers:
heights = [61, 70, 67, 64]
70) is separated by a comma (
) after each comma, but your code will run just fine if you forget the space.
A new student just joined the class:
Add Cole’s height to the end of the list
# in front of the definition of the list
broken_heights. If you run this code, you’ll get an error:
SyntaxError: invalid syntax
Add commas (
broken_heights so that it runs without errors.