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 trialLening Li
689 PointsNot sure how to create a variable called item3.
what's the value of item3? Tuple is immutable.
# insert your code here
my_tuple = 'I', 'love', 'python'
my_tuple = list(my_tuple)
my_tuple[2] = 'item3'
my_tuple = tuple(my_tuple)
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsHey Lening Li, your first line is correct for Task 1. Items separated by comma form a tuple. Some coders wrap the items in parens to visually mark the tuple, but this is unnecessary as the commas make the tuple not the parens.
For Task 2, βitem3β is a label so it goes on the left side of the =. On the right side goes the definition. Tuples can be referenced using indexing in the same manner as lists, so the third item can be referenced using [2]. More it is zero-based numbering: 0, 1, 2, etc. making 2 the third item.
Your second to last line of code above would be correct if the sides were switched around the equals sign. Since youβre defining a new variable and not a string, the quotation marks are not needed around item3
.
Post back if you need more help. Good luck!!