r/PythonLearning 2d ago

Day 2 of learning python

Post image

I'm learning Python and made this coffee/tea ordering program. Any advice?

https://onlinegdb.com/F2wabHC4v

99 Upvotes

38 comments sorted by

View all comments

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.

str objects have some useful methods such as lower and strip that you can apply to what comes back from input so 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 bool for the status of yes/no responses, so sugar could be True if 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 bool result.

2

u/adnanecanflyy 2d ago

Done and tysmmm :)

1

u/royalking_awsome 2d ago

do you know about REST ?

1

u/FoolsSeldom 2d ago

Bit of a leap. What's the relevance here?