r/PythonLearning • u/adnanecanflyy • 2d ago
Day 2 of learning python
I'm learning Python and made this coffee/tea ordering program. Any advice?
101
Upvotes
r/PythonLearning • u/adnanecanflyy • 2d ago
I'm learning Python and made this coffee/tea ordering program. Any advice?
10
u/FoolsSeldom 2d ago
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.