I've written a BMI calculator but I'd like there to be a way to ensure the user only types numbers so, if something else was input the question was to be asked again. Here's some of my code.
#Ask whether metric or imperial is to be used and ensures no typing errors
measure = input("Would you like to use Metric or imperial measurements? Please type i for imperial or m for metric \n")
while(measure != "i") and (measure != "m"):
measure =input("Please type a valid response. Would you like to use Metric or imperial measurements? Please type i for imperial or m for metric")
#Asks the users weight
if(measure == "i"):
weights = input("Please type in your weight in stones and pounds- stones=")
weightlb = input("- pounds=")
weights = int(weights)
weightlb = int(weightlb)
weight = (weights*14)+weightlb
elif(measure == "m"):
weight = input("Please type in your weight in kilograms=")