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 trialAngad Chadha
1,467 PointsWhat is the need of writing the variable new_item in function add_to_list(new_item)?
What is the need of writing the variable new_item in function add to list?My code worked fine when I removed the new_item variable from the function add to list()
1 Answer
Viraj Deshaval
4,874 PointsArgument new_item should be passed while calling to the add_to_list function. The function called within the loop and new_item variable we have inside of the loop. So this has to be passed. I bet what you have done is you kept shopping_list.append(new_item) as is in the while loop and also created function add_to_list and that's the reason it's working without argument. Let me know if you need any more help.
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsCould you post the code with this behavior for better feedback? Thanks!