Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

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
42,986 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!