May-26-2020, 08:07 AM
I wanted to write a little code that takes in a number. If the number is within a specified range, 0.0 to 1.0, no exception is thrown. But if it is outside the range, the program should prompt the user to input another number. I don't seem to be getting the prompting right when the exception happens. Instead of prompting the user for a new number, the code just fails. Please can anyone tell me what is wrong? The code is below.
Score = input('enter number between 0 and 1\n') try : Score = float(Score) if Score >= 0.0 and Score <=1.0 : print('correct number') except: print('enter correct number')