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

kosi Ofodum
kosi Ofodum
192 Points

Create a variable called item3 and assign to it the third element in my_tuple?

how do i do this

my_tuple = 'I', 'love', 'python'

1 Answer

Steven Tagawa
.a{fill-rule:evenodd;}techdegree seal-36
Steven Tagawa
Python Development Techdegree Graduate 14,238 Points

Honestly, I had to re-read this challenge a couple of times to figure out what they were asking... They just want you to take the third item in the tuple (which is 'python') and put it in a new variable called 'item3'. So you start with

item3 = 

You get to items in a tuple the same way you do with lists, with brackets [] and remember that it starts at zero, so the third item is [2]. So you end up with

item3 = my_tuple[2]