[英]Python- Currency converter not real time
You are taking the currency input in a wrong way.您以错误的方式输入货币。 Replace with this code:
替换为以下代码:
amount = int(input("Please enter an amount to convert"))
if con=='a':
print(amount,'converts to ',amount*0.57)
Also, to add more currency types, instead of typing everything, just put them in an array in this way:此外,要添加更多货币类型,而不是键入所有内容,只需将它们以这种方式放入数组中:
currencies = [['CAD','GBP'],['CAD','USD'],['CAD','JPY'],['CAD','EUR']]
for i in range(len(currencies)):
print(i+1,' ',currencies[i][0],' to' ,currencies[i][1])
#change alphabet to integers
con = int(input("Please select the type of conversion"))
if con == 1:
print(amount,' ',currencies[i-1][0], converts to ',currencies[i-1][1],amount*0.57)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.