Locked lesson.
About this lesson
Python lists are used to keep track of a list of items. They can be text, numbers, variables, other lists and more.
Exercise files
Download this lesson’s related exercise files.
8 - Python Lists.docx57 KB 8 - Python Lists SOLUTION.docx
55.5 KB
Quick reference
Python Lists
Python lists are used to keep track of a list of items. They can be text, numbers, variables, other lists and more.
When to use
Use them whenever you need to keep track of a list of things.
Instructions
To create a list, just name it and use square brackets:
names = ["John", "Bill", "Tina"]
Separate each item of the list by a comma. Text should be wrapped in quotation marks, numbers, variables, and other lists should not be wrapped in quotes.
List items are numbered, and start with zero.
To access an item in that list, simply reference its list number.
To reference John in the list above:
names[0]
Hints & tips
- names = ["John", "Bill", "Tina"]
- names[0]
- List items are numbered and start at zero.
Lesson notes are only available for subscribers.