Skip to content
New: in-browser code execution engineSee it now

Advanced Python · Week 3

Tuples

Step 1 of 5

Exercise 1: Introduction to Tuples

Welcome to Python 2, Lesson 3! Today, we'll learn about tuples, another important data structure in Python.

What is a Tuple?

A tuple is an ordered, immutable collection of elements. This means once you create a tuple, you can't change its contents.

Here's how to create a simple tuple:

# Create a tuple of fruits
fruits = ("apple", "banana", "cherry")

print(fruits)
print(type(fruits))

Now it's your turn! Create a tuple called colors with the following items:

  • red
  • green
  • blue

After creating the tuple, print it and its type to see the result.

Starter code
# Create the colors tuple here

# Print the tuple and its type

Write your code here

python