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 The Application

I have the exact same code as Craig in the video but my code won't run like his does [Solved]

def show_help(): 
    print("What should we pick up at the store?")
    print("""
Enter 'DONE' to stop adding items.
Enter 'HELP' for this help.
""")

show_help()
while True: 
    new_item = input("> ") 

    if new_item == 'DONE': 
        break
    elif new_item == 'HELP': 
        show_help()
        continue

[MOD added ```python formatting -cf]

Sorry I think some of the code got cropped out of the screen where it shows the syntax

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

What is different than you expect?

Are you running your code using python shopping_list.py at a linux or workspace command window prompt?

I can run your code:

$ python help_app.py 
What should we pick up at the store?

Enter 'DONE' to stop adding items.
Enter 'HELP' for this help.

> blah
> blah
> HELP
What should we pick up at the store?

Enter 'DONE' to stop adding items.
Enter 'HELP' for this help.

> DONE
$

I am running the code in a Treehouse Workspace with the file name shopping_list.py and I have run it with the command: python shopping_list.py

Oh and also, when I say HELP when the arrow is pointing it doesn't show the Enter 'DONE' print but instead continues to print more inputs

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

It is possible you're running is a different workspace, or perhaps not have saved you most recent edits?

In the upper right of the workspace is a camera icon. Select that to take a snapshot of your workspace. This creates a link you can share here for me to try your code in the exact same environment.

1 Answer

SORRY, I found the problem, when I was putting HELP into the input I accidentaly added a space after I said HELP. That made the code think the string was 'HELP ' instead of 'HELP'.