mercredi 24 novembre 2021

Trying to get my code to input only digit values and if it inputs a non digit value it prints You have input a non digit value but its not working

menu()
selection=float(input("Select a menu- Input a number:"))
if selection==1:
    print("::menu 1::")
elif selection==2:
    print("::menu 2::")
elif selection==3:
    print("::menu 3::")
elif selection==4:
    exit
elif selection<=0 or selection>4:
    print("There is no menu",end=" ")
    print(selection)
else:
    print("You have input a non digit value. Select again:")

it seems to only recognise decimals as non digit value but if i wear to write a word it would say could not convert string to float-How do i fix this im new to programming

Aucun commentaire:

Enregistrer un commentaire