Locked lesson.
About this lesson
Tuples are just like lists, but they can't be changed once created. Let's discuss how to create and reference them.
Exercise files
Download this lesson’s related exercise files.
9 - Python Tuples.docx57.1 KB 9 - Python Tuples SOLUTION.docx
55.4 KB
Quick reference
Python Tuples
Tuples are just like Lists, but they can't be changed once created.
When to use
Use these when you want to deal with data that can't be changed.
Instructions
To create a tuple, just name it:
names = ("John", "Mary", "Tim")
To access an item in the Tuple, reference its item number.
To access John:
names[0]
Hints & tips
- names = ("John", "Mary", "Tim")
- names[0]
- Tuples can't be changed once they are created.
Lesson notes are only available for subscribers.