May-28-2020, 04:38 PM
(May-27-2020, 08:00 AM)buran Wrote: It's better to be specific as to what problem is
while True : score = input('Number between 0 and 1\n') try : score = float(score) if 0 <= score <= 1: break else: print('Number must be between 0 and 1, inclusive. Please try again...') except ValueError: print('Not a number. Please try again...') print(f'You entered: {score}')Now, if you want to go a step further you can put [part of] this code in a function that takes start and or end argument, ask user for input, validates it and returns the number once correct input.
Thanks. I will implement this suggestion. It's more intuitive.