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 Shopping List Take Three

In add_to_list() function in the video, Kenneth is using both new_item and item when adding to the shopping_list.

In add_to_list() function in the video, Kenneth is using both new_item and item when adding to the shopping_list.

Why does he not get ValueError since the add_to_list() function takes item as an input argument, but he is appending new_item to it.

nakalkucing
nakalkucing
12,964 Points

Are you getting an error?

2 Answers

Steven Parker
Steven Parker
231,248 Points

The variable "new_item" is a global that is created in the main loop, and in fact is what is passed as an argument in the call to "add_to_list".

So while it does not cause an error, it's not good programming practice and the parameter name "item" should be used instead. I strongly suspect this was unintentional and went unnoticed primarily because there was no error.

You might want to report this as a bug to the Support folks. They might add something to the Teacher's notes, and you could get an "exterminator" badge. :beetle:

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Great catch prparekh !

I will take care of this in the notes and fix it when it refreshes. Thank you!

You've just earned the illustrious Exterminator badge!

Thank you again for your help!

Thanks, Craig. Here's another one:

Challenge Task 2 of 2
https://teamtreehouse.com/library/python-collections-2/sets/set-math
The last line of the challenge should say:
Java Basics and PHP Basics would be excluded because they don't include both of those topics
instead of
Java Basics and PHP Basics would be exclude because they don't include both of those topics

Craig Dennis
Craig Dennis
Treehouse Teacher

Thanks! @prparekh ! I'd give you another badge if I could ;) Thanks again!