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 trialHoma Shayan
2,038 Pointsfor the manipulating list 2nd part code challenge I used: del the_list[1] del the_list[4] del the_list[5] got error
the_list.insert(0,the_list.pop(3)) del the_list[1] del the_list[4] del the_list[5]
says first task not passing anymore.
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]
# Your code goes below here
the_list.insert(0,the_list.pop(3))
del the_list[1]
del the_list[4]
del the_list[5]
1 Answer
Kenneth Love
Treehouse Guest TeacherThe list starts off with 6 items, so the last item, the inner list, is index 5. When you delete two items, now the last item's index is 3, not 5, so you can't do del the_list[5]
anymore.
Ahmed Elsawey
Courses Plus Student 3,527 PointsAhmed Elsawey
Courses Plus Student 3,527 PointsHow would you do it then? Kenneth Love
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherWell, this particular part I'd do with
del the_list[3]
since that's the last index.Ahmed Elsawey
Courses Plus Student 3,527 PointsAhmed Elsawey
Courses Plus Student 3,527 PointsTo be honest I used to love programming until it came to the dictionaries lists and tuples, I have no idea what to do in them and I copy the answer from some questions without even understanding them.
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherAww, I don't want you to hate programming!
What are some things that confuse you about dicts/lists? Feel free to email me if you want.
Ahmed Elsawey
Courses Plus Student 3,527 PointsAhmed Elsawey
Courses Plus Student 3,527 PointsWhat is your email?
Ahmed Elsawey
Courses Plus Student 3,527 PointsAhmed Elsawey
Courses Plus Student 3,527 PointsFor example now, I do not know how to do task 2 of this challenge
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherYou've gotten an email from me with every badge :) kenneth@teamtreehouse.com
Ahmed Elsawey
Courses Plus Student 3,527 PointsAhmed Elsawey
Courses Plus Student 3,527 PointsWhat email did you send it too again? ???