Complete-Python-3-Bootcamp icon indicating copy to clipboard operation
Complete-Python-3-Bootcamp copied to clipboard

62. Validating User input (Shortcut)

Open ManzarMaaz opened this issue 1 year ago • 0 comments

def user_choice(): valid_range = range(0,11) choice = 'ABCDE'

while choice.isdigit() == False or int(choice) not in valid_range:
    choice = (input('Please select a Number (1-10) :\n'))
    print(f"Let's Try, Select only from (1-10) : {choice}")

return(int(choice))

ManzarMaaz avatar Jun 24 '24 15:06 ManzarMaaz