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
cheyenne hemmati
1,195 PointsIntroduction To Tuples
in the teacher example... tuple_with_a_list = (1, "apple", [3, 4, 5]) tuple_with_a_list[2][1] = 7
why did the 4 change to a 7 is [2][1] referring to index [3] which is 4? thanks
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! There is no index [3] as you put it. Remember, many computer languages start counting the indexes starting from 0. At index 0 we have 1. At index 1 we have "apple". But index 2 contains yet another list inside a list. It also starts counting at 0. So at [2][0] we have 3, at [2][1] we have 4 and at index [2][2] we have 5. It was the [2][1] that was reassigned a value of 7 so the 4 gets changed out to a 7. At the end of this, our list will look like this:
(1, "apple", [3, 7, 5])
Hope this helps!
cheyenne hemmati
1,195 Pointscheyenne hemmati
1,195 Pointsthank you Jennifer!