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 trialNick Evershed
6,429 PointsPrinting wrong snack
Soda
sodas = ["Pepsi", "Cherry Coke", "Sprite"]
Crisps
crisps = ["Doritos", "Quavers", "Walkers"]
Sweets
sweets = ["Snickets", "Skittles", "Crunchies"]
while True: choice = input("Soda, Crisps, Sweets: ").lower() if choice == 'soda': snack = sodas.pop() elif choice == 'crisps': snack = crisps.pop() elif choice == 'sweets': snack == sweets.pop() else: print("Sorry, I didn't understand that") continue print("Here's your {}: {}".format(choice, snack))
1 Answer
KRIS NIKOLAISEN
54,972 PointsFor sweets you have:
snack == sweets.pop()
instead of:
snack = sweets.pop()
Nick Evershed
6,429 PointsNick Evershed
6,429 PointsOh dam, what does that do?
Stephen Falck
7,558 PointsStephen Falck
7,558 PointsThe '==' checks if they are equal, as opposed to assigning the value of sweets.pop() to the snack variable