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 Pop

Tried to run code in console, nothing popped up?

I practiced typing the code like in the video, checked and mine was basically the same as the video. But when I typed into the console, the program didn't run, it just reprinted the treehouse input again. Like this:

treehouse:~/workspace$ python vending_machine.py
treehouse:~/workspace$ python

It might be just a technical thing, but thought I'd ask just to make sure.

The code I typed in is below, and the indentations are aligned correctly: sodas = ["Pepsi", "Cherry Coke", "Root Beer"] chips = ["Doritos", "Fritos", "Seaweed chips"] candy = ["Snickers", "Twizzlers", "Gobstoppers"]

while True: choice = input("Would you like a SODA, some CHIPS, or some CANDY? ").lower() if choice = 'soda': snack == sodas.pop() elif choice == 'chips': snack == chips.pop() elif choice == 'candy': snack == candy.pop() else: print("Sorry, I did not understand that.") continue print("Here's your{}: {}".format(choice, snack))

Please use Markdown so that we can more clearly read your code. (Learn markdown in a couple seconds from the Markdown Cheatsheet below the answer box :arrow_heading_down: !)

James Smith
James Smith
Courses Plus Student 752 Points

Put your actual text editor here so that we can see how you actually typed it all out

1 Answer

Well, your code should have nothing to with what happened in the workspace terminal. It's likely that that the last command, before you tried to run the script, was python And i'm guessing you may have pressed the 'up' arrow key instead of 'enter'. Doing this will bring up the last command run in the terminal.

On a side note, after parsing through your pasted code, I noticed that you have a syntax error:

if choice = 'soda':
# should be
if choice == 'soda':