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 Collections (2016, retired 2019) Lists Removing Items From A List

Name Error on my code dont know how to fix it

On line 52 i get a name error and dont know how to fix it. https://w.trhou.se/aa8ecndqob

Johannes Scribante
Johannes Scribante
19,175 Points

Hi Bryan,

A NameError normally occurs when a variable/function name is not defined.

If it says you get a NameError on line 52, go look at what variables/functions are used and make sure each of them are defined before they are used. Hope that helps.

1 Answer

Steven Parker
Steven Parker
231,275 Points

On both lines 44 and 52 the code references a variable named "item" which has not been defined either globally or in the function.

Did you intend to reference the passed argument "new_item" instead?

thanks man thats what i was thinking. The reason i didnt change it was becuase in the video thats how he typed it and it didnt throw an error. I wonder if he defined item somewhere lol. Just means I should trust in myself a lil bit more

Steven Parker
Steven Parker
231,275 Points

Did you watch the entire video? Ken's been known to demonstrate making and later fixing errors. If this is not one of those cases, you might want to report it as a bug in the video to Support.