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 Introducing Lists Build an Application Display the List

Chris Leonard
Chris Leonard
3,018 Points

Why do you hardcode shopping_list into the for loop in your show_list function? Shouldn't it be taken as a parameter?

I ended up using:

def show_list(list):
    print("Your current shopping list: ")
    for item in list:
        print("*  " + item)

In this small application example, it may not be necessary, but isn't it logical to reinforce that point now, so that when someone gets to the point where code reuse and extensibility matters, they're already in the habit? (An example for this is what if you get another user story, and they want a grocery store list and a hardware store list?)

1 Answer

Steven Parker
Steven Parker
231,269 Points

The example project was probably made specific to keep the focus on the particular techniques being taught. But from the concepts of "best practice" in the program overall, you have a very good idea! :+1:

Don't forget to also change the other functions (such as "add_list") if you want to generalize the entire program.