How to handle try/exception block in python?

Combining question text and comments, I assume that you wonder why the program does output erroneous input as largest. The answer to this is that you should move the try block checking your input right before the update of largest and smallest. Also it might be helpful to not use another variable n for the result of the conversion, but try num = float(num) after checking num for "done".

(As this is obviously homework, I will not post the “solution”, but leave it with the hints.)

Browse More Popular Posts

Leave a Comment