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

Python

help

my_list = [1, 4, 2, 3]

I want to delete the 4 my from my_list using del.

___________ my_list[________________]

my answer:

del and 4

http://teamtreehouse.com/library/removing-list-items

2 Answers

The question is asking you to delete the 4. When you call mylist[index] you are calling a command on that list at the index of the index. Right now, you are removing the number in the index of 4 not the number four.

If you have a list of mylist[index1, index2, index3, index4] and you want to remove the second index, you do del mylist[1].

(Remember that Python starts counting at 0.)

The answer you're looking for is del mylist 1; because the 4 is the second number in my_list = [1(0), 4(1), 2(2), 3(3)] Therefore del mylist 1