Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Tuples Getting to Know Tuples Creating Tuples

how to use index

how to use index

creating_tuples.py
my_tuple = "I", "love", "python"
item3 = my_tuple

2 Answers

boi
boi
14,242 Points

You can use indexing by placing an index number into a square bracket [].

my_tuple = "I", "love", "python"
item3 = my_tuple


print(len(item3))

print(item3[0])
print(item3[1])
print(item3[2])

print(my_tuple[0])
print(my_tuple[1])
print(my_tuple[2])
Rick Gleitz
Rick Gleitz
47,878 Points

You're almost there. Your tuple strings need to have parens around them (I don't know why the first task passed without them), and for this task you need to specify the index value of the third element in square brackets. Since the elements begin at zero, the third one is 2. Hope this helps!