I'm writting a piece of program in which I ask for input from user.
I want python to check if the input is digit (not words or puntuation...) and if it is a number indicating an object in my tuple. If one of the 3 conditions result in False then I would like the user to provide another value for that variable. Here's my code
colour={'yello':1, 'blue':2, 'red':3, 'black': 4, 'white': 5, 'green': 6}
height_measurements=('centimeter:1', 'inch:2', 'meter:3', 'foot:4')
weight_measurements=('gram:1', 'kilogram:2', 'pounds:3')
print height_measurements
hm_choice = raw_input('choose your height measurement').lower()
while not hm_choice.isdigit() or hm_choice > 0 or hm_choice < len(height_measurements) :
hm_choice = raw_input('choose your height measurement').lower()
print weight_measurements
wm_choice = raw_input('choose your weight measurement').lower()
while not wm_choice.isdigit() or wm_choice > 0 or wm_choce < len(weight_measurements) :
wm_choice = raw_input('choose your weight measurement').lower()
When I put this to test, it kept making me insert input for height_measurement constantly no matter what I put in
Please check my code and correct for me. Also if you will, please provide me with better code of yours.