[英]Python- Currency converter not real time
您以錯誤的方式輸入貨幣。 替換為以下代碼:
amount = int(input("Please enter an amount to convert"))
if con=='a':
print(amount,'converts to ',amount*0.57)
此外,要添加更多貨幣類型,而不是鍵入所有內容,只需將它們以這種方式放入數組中:
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.