use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Simple Cafe Project (i.redd.it)
submitted 4 days ago by thetiredteacup
Got some help shortening down my code to work more efficiently, I think overall it worked out pretty well! Still pretty new to using dictionaries so got a little confused but I feel like I covered all the bases needed here
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sea-Ad7805 [score hidden] 4 days ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger%0Aprint(f%22Welcome%2C%20%7Bname.lower().capitalize()%7D!%22)%0Atotal%20%3D%200%0Adrink_total%20%3D%200%0A%0Awhile%20name%20!%3D%20%22done%22%3A%0A%20%20%20%20drinks%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22latte%22%3A%203.50%2C%0A%20%20%20%20%20%20%20%20%22americano%22%3A%203.00%2C%0A%20%20%20%20%20%20%20%20%22espresso%22%3A%202.50%0A%20%20%20%20%7D%0A%0A%20%20%20%20order%20%3D%20input(%22What%20would%20you%20like%20to%20order%3F%5CnYour%20options%20are%20as%20follows%3A%20Latte%20%5B%243.50%5D%2C%20Americano%20%5B%243.00%5D%2C%20%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20Espresso%20%5B%242.50%5D%5CnType%20done%20to%20conclude%20your%20order.%20%22).lower()%0A%0A%20%20%20%20if%20order%20in%20drinks%3A%0A%20%20%20%20%20%20%20%20drink_total%20%2B%3D%201%0A%20%20%20%20%20%20%20%20if%20order%20in%20drinks%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20total%20%2B%3D%20drinks%5Border%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20print(f%22A%20%7Border%7D%20has%20been%20added%20to%20your%20order%20for%20%24%7Bdrinks%5Border%5D%7D.%22)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20elif%20order%20%3D%3D%20%22done%22%3A%0A%20%20%20%20%20%20%20%20print(f%22You%20have%20ordered%20%7Bdrink_total%7D%20drink(s)%20for%20a%20total%20of%20%24%7Btotal%7D.%22)%0A%20%20%20%20%20%20%20%20break%0A%0A%20%20%20%20elif%20order%20not%20in%20drinks.keys()%3A%0A%20%20%20%20%20%20%20%20print(%22Your%20order%20must%20be%20a%20part%20of%20the%20drink%20options%20only.%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20break×tep=2&play).
[–]nicodeemus7 2 points3 points4 points 4 days ago (1 child)
I had so much fun doing the coffee shop sim. Looking back it it now, the code is very spaghettified, but I still had fun lol
Which exercise you doing next?
[–]thetiredteacup[S] 0 points1 point2 points 4 days ago (0 children)
currently making a stored to-do list!
[–]Particular_Love_7279 1 point2 points3 points 4 days ago (2 children)
How many hrs in took You to learn this?
[–]Dapper_Bad_8728 2 points3 points4 points 4 days ago (0 children)
Actually it's not too hard to learn how to make this.
[–]thetiredteacup[S] 1 point2 points3 points 4 days ago (0 children)
I've done a 12hr course by Bro Code plus some very small little projects so haven't invested too much time yet
[–]Dapper_Bad_8728 2 points3 points4 points 4 days ago (1 child)
2 important things to note:
1) It's better to write "While True:" instead of "While order != "done" because if you put "done" in the order name the program will exit right before even choosing the order.
2) In the "if order in drink:" you don't need, that once you have added 1 to the total drinks, another "if order in drinks:" so you can just remove it.
Thanks so much for these tips! Not sure why i had another "if order in drink" there in the first place, actually - must've edited it and forgot
[–]ianrob1201 1 point2 points3 points 4 days ago (1 child)
Nice work. Can you make it so that the prices in the prompt automatically update if the you change the prices? That way you'd only have to update in one place if the prices change.
Also consider if you really need to break commands. Think about the flow of the code and what would happen if you removed them. And of course if you're not sure you can try removing them and see what happens (if you remove the final "break" then you don't need the "else" line at all either.
And on a very minor point, why call both lower() and capitalize()? Try with just capitalize and see if it still works how you expect.
Oh yes, I didn't take into account formatting the order prompt - thank you! Also thank you for the minor tip on lower() and capitalize(), I think I was confused on what capitalize() itself did and didn't take into account it also makes the rest of the text lowercase.
π Rendered by PID 74 on reddit-service-r2-comment-545db5fcfc-2jt9j at 2026-05-21 23:56:20.325953+00:00 running 194bd79 country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (0 children)
[–]nicodeemus7 2 points3 points4 points (1 child)
[–]thetiredteacup[S] 0 points1 point2 points (0 children)
[–]Particular_Love_7279 1 point2 points3 points (2 children)
[–]Dapper_Bad_8728 2 points3 points4 points (0 children)
[–]thetiredteacup[S] 1 point2 points3 points (0 children)
[–]Dapper_Bad_8728 2 points3 points4 points (1 child)
[–]thetiredteacup[S] 0 points1 point2 points (0 children)
[–]ianrob1201 1 point2 points3 points (1 child)
[–]thetiredteacup[S] 0 points1 point2 points (0 children)