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 trialWilliam Harpley
20,792 Pointsmessy_list Step 2 error
Not sure why I keep getting this error on step 2 of the Python messy_list challenge.
AttributeError: 'NoneType' object has no attribute 'copy'
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
messy_list = messy_list.insert(0,messy_list.pop(3))
loop_list = messy_list.copy()
for item in loop_list:
if type(item) is not int:
messy_list.remove(item)
1 Answer
Grigorij Schleifer
10,365 PointsHi William, your code works just fine in the workspace. I removed the assignment part at the second line and could pass the challenge. To be honest I have no clue why it didn't pass in the first place. But the interpreter is sometimes very picky. Maybe it doesn't like the new colors and is upset
messy_list = ["a", 2, 3, 1, False, [1, 2, 3]]
messy_list.insert(0,messy_list.pop(3)) # assignment removed
loop_list = messy_list.copy()
for item in loop_list:
if type(item) is not int:
messy_list.remove(item)
I hope that helps
William Harpley
20,792 PointsWilliam Harpley
20,792 PointsI came back to this a few days later, and the interpreter like your code better. Tricky little interpreter... appreciate the help :)
Grigorij Schleifer
10,365 PointsGrigorij Schleifer
10,365 PointsHa ha, oh yes ... the interpreter is a drama queen