Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,045 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.