mardi 30 novembre 2021

How to create return to x?

while True:
        print("Welcome to this BMI calculator")
        x = str(input("Are you using Pounds or Kg, if you are using Kg press K if you are using Pounds press P:"))
        if x in ['P', 'p']:
            h = float(input("Key in your weight:"))

        elif x in ['K', 'k']:
            h = float(input("Key in your weight:"))

        else:
            **return(x)**
            print(x)
   

Bold indicates error and how to return if the user does not key in any of the characters (P/p/K/k)

Aucun commentaire:

Enregistrer un commentaire