Prince-linux / python-learning

for learning Python
MIT License
1 stars 0 forks source link

add: both conversions are in a single try-except #21

Closed lcabrini closed 9 years ago

lcabrini commented 9 years ago

The add script uses a single try-except block to capture both inputs and attempt to convert them to integers. The problem with this approach is that if you type the first number correctly but not the second one, you would be asked to enter both numbers again. This doesn't make much sense and is also "unfair" to the user. It is not good from a user interaction point of view.

So split the input section into two. Ask the user for the first number and attempt to convert it. If that is successful, move on to the second number.