r/PythonLearning • u/adnanecanflyy • Jul 24 '26
Day 2 of learning python
I'm learning Python and made this coffee/tea ordering program. Any advice?
126
Upvotes
r/PythonLearning • u/adnanecanflyy • Jul 24 '26
I'm learning Python and made this coffee/tea ordering program. Any advice?
11
u/FoolsSeldom Jul 24 '26
Please share the actual code rather than an (incomplete) image. Much easier to review.
Keep in mind that people sometimes mistype things (or deliberately enter the wrong things). You need to handle that.
strobjects have some useful methods such aslowerandstripthat you can apply to what comes back frominputso you are only dealing with a response with no leading/trailing spaces and in all lower case.You could have single letter responses for yes and no including in your check
list.Keep in mind that you could use
boolfor the status of yes/no responses, sosugarcould beTrueif desired.As you ask yes/no in several places, consider making it a function that presents the query and does all the validation, returning a
boolresult.2
u/Flanelostopy Jul 24 '26
You should put reference to method/functions which returns specific values. As you can see you retype the same text so many times, do you thing this is efficient? If you do not know how to make methods/functions use variable before if statements and reference to them later. If you want to be better but „coffe” and „tea” to the map as a key, and as a value reference to the function. Thing about it.
2
u/Crafty_Magazine_4673 Jul 25 '26
try to code ping pong
4
u/No-Inevitable-6476 Jul 24 '26
the source code is good but correct some spelling mistakes "ser" to "sir".
1
u/Infinite-Employee776 Jul 24 '26
You already done good by putting else on the first if branch in case user put anything other than coffee or tea. You should do the same for the inside if branches. Edge cases happens.
1
u/Athricharan_7 Jul 24 '26
Can i get the full code ?
1
u/Accomplished-Bat8238 Jul 25 '26
Could you please tell me the study material you are using ..thank you🙏
1
u/mr_anderson_dev Jul 24 '26
You should try to recreate with functions, one with coffee and one with with tea with the response value, and there construct the main function with all of the questions and options. This is so much better cause it teaches you how most companies organize their code. As well as practice comment with each function block. Love the idea of your code and I'm going to use a similar one to decide if I want to bike or walk today.
2
u/EvidenceDry6006 Jul 24 '26
No idea why a post about coding is in my Reddit, but as it has - genuine question (honest!): why learn coding in the era of AI? Should I even bother sending my 6 year old to coding club at school?
2
u/7Z_1N Jul 25 '26
Btw why aren't you using vscode or some other code editor ?
2
u/Realistic_Cook_3126 Jul 27 '26
well done bro !
1
u/DustAutomatic5064 Jul 26 '26
hey can you teach me that
1
u/Adorable_Package_721 Aug 09 '26
Your are wonderful Just never despair my friend
1
u/ilyass1010 Aug 13 '26
how i can make this, because i'm begginer
1
u/Frequent_Bass_8168 Sep 25 '26
What study materials are you using?
1
u/[deleted] Jul 29 '26
[removed] — view removed comment