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 trialLakshit Kerai
3,816 PointsWhich 1 are they talking about there are two in the list?
also can we write it in one line like so
the_list = the_list.insert(0, the_list.pop(3))
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]
# Your code goes below here
one = the_list.pop(3)
the_list = the_list.insert(0, one)
1 Answer
andren
28,558 PointsThey are talking about the first "1", the second "1" is not technically in the list by itself, it is inside another nested list within the list.
And your one line example is mostly correct, the thing is that .pop and .insert modify the list you use them on, they don't return a modified list. Therefore you don't have to assign the list variable to the result of using .pop or .insert on the list like you do. You can just use .pop and .insert without assigning it to a variable like this:
the_list.insert(0, the_list.pop(3))
That code will allow you to pass task 1.
Lakshit Kerai
3,816 PointsLakshit Kerai
3,816 PointsThanks andren! You cleared a major misunderstanding that I had.