Python Tuple Exercises

Let’s check out some exercises that will help understand tuples better.

Exercise 7-a

Assign the first element of the tuple to answer_1 on line 2


tuple[index]

Correct syntax to call a tuple’s element is brackets with the index number inside next to the tuple’s name: 

 

Index starts with zero.

answer_1 = tt[0]

Exercise 7-b

This time print the third element of the tuple.


0,1,2 … Third element is index 2: [2]

answer_1 = tt[2]