Lists · practice
Create a List
You create a
Python prints the brackets, commas, and quotes so you can see the list structure. The call to type() reports list.
Values first, name second
The right side of an
Spaces after commas are not required by Python, but they make the list easier to read. A list can also span several lines:
The trailing comma after the last item is allowed. It makes later editing convenient, but you do not need it for a short one-line list.
Count the items, not the punctuation
This list contains three items:
You already used len() with
What does this code print?
drinks = ["tea", "coffee"]
print(len(drinks))Your turn
In the editor, replace the empty list with the three destinations named in the instructions. Printing the whole list lets you check both its values and their order. Three items, one list, and much less name juggling.
Task
Create a destinations containing exactly these three
"Lisbon""Seoul""Nairobi"
Then print the complete list.