r/PythonLearning • • 9h ago

Help Request How can I improve?

Post image
2 Upvotes

2 comments sorted by

2

u/noragerts 4h ago

For more than three cases I would recommend using switch statements. I think in Python it's called match-case as I recall. Personally I find it easier to read when that happens

2

u/Ceteris__Paribus 2h ago

You could try converting to floats before you go to resolve the expression. If someone enters "potato" for num1 the program will still ask for num2 and operation before throwing an error later on. This would also make the test of the code read easier.

You also are not catching division by zero errors which is fine because the program is ending anyway, but as a programmer you should think about what exceptions could be raised when you write code.