Locked lesson.
About this lesson
What is a tuple and how is it different from a list?
Exercise files
Download this lesson’s related exercise files.
Tuples.docx60.3 KB Tuples - Solution.docx
58.9 KB
Quick reference
Tuples
In this lesson we'll look at tuples, which are very similar to lists.
When to use
Use a tuple when you have data that won't ever change.
Instructions
Create a tuple just like you would a list, but instead of [ ] brackets, use ( ) parenthesis.
my_tuple = ("John", "Tim", "Mary)
To call an item from a tuple:
print(my_tuple[1])
Hints & tips
- Tuples are just like lists, only you can't change them after they have been created
- Tuples may be slightly faster, performance wise, than a list
Lesson notes are only available for subscribers.