I am trying to make a program that asks you for a currency that is stated. And I want to make a while loop that repeats enter a currency until a correct currency is inputed. However when I hit run it says error right where i entered the while loop
#current currency == num1
num1 = str(input("Exchangeable currencies: usd, eur, cad, inr, jpy, vnd, krw, btc. Enter
current currency"))
#target currency == num2
num2 = str(input("Enter target currency"))
num1amount = int(input("Enter amount of money"))
list ["usd", "eur", "cad", "inr", "jpy", "vnd", "krw", "btc"]
while num1 or num2 != from list:
print "wrong currency: "
#current currency == num1
num1 = str(input("Exchangeable currencies: usd, eur, cad, inr, jpy, vnd, krw, btc.
Enter current currency"))
#target currency == num2
num2 = str(input("Enter target currency"))
num1amount = int(input("Enter amount of money"))
break
您的代码中有几个错误,但关于 while 循环,您可能希望执行以下操作:
while ((num1 not in list) and (num2 not in list)):
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.