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!

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 do i assign a variable to an element in a tuple

Where exactly am i going wrong

1 Answer

Chris Kisselburgh
Chris Kisselburgh
2,173 Points

Hey Malcolm,

Remember that tuples are immutable meaning they can't be modified once the data is stored inside of one. With that in mind, you access items in tuples using their position index inside of square brackets.

my_tuple = ('dog', 'cat', 'bird')

This code should return the string 'cat' as the position index in python always starts at the number 0. Instead of printing the variable like I did in my example, you could just assign it to a new variable as well.

Hope this helps!