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 Python Basics (2015) Python Data Types List cleanup

gurinder singh
PLUS
gurinder singh
Courses Plus Student 1,422 Points

why this is not ryt??

why showing error??

lists.py
messy = [5, 2, 8, 1, 3]
del messy[1]

2 Answers

del messy[2] <--- the index must be 2 to delete the third element ("8"), since the array elements start with index 0

gurinder singh
PLUS
gurinder singh
Courses Plus Student 1,422 Points

in the first exercise, they said to delete "8" in which I put (del messy[2]) and now in 2 they are saying to delete "2" in which I put (del messy[1] )and it's showing me an error.

messy = [5, 2, 8, 1, 3]

del messy[2]

del messy[1] <----- write another line of code for the second task , exercise 1 will be affected if you dont write another line of code