lundi 6 avril 2020

If statement not working inside of while loop [closed]

The if/else statement inside of this loop will not work. When I input currency = "usd", currency1 = "ntd", it still working in the first if... the program do not calculator the second if! I don't understand why, any help would be appreciated.

command = ""
while command != "quit":
    cmd = input("> ").lower()
    if cmd == "exchange":
        amount = float(input(">Amount: "))
        currency = input(">From: ").upper()
        currency1 = input(">To: ").upper()
        if currency == "usd" and currency1 == "ntd":
            result = amount / 30.20
            print(result)
        elif currency == "ntd" and currency1 == "usd":
            result1 = amount * 30.20
            print(result1)
    elif cmd == "quit":
        break
    else:
        print("Error!")
        break

Aucun commentaire:

Enregistrer un commentaire