首页 > 解决方案 > Python-货币转换器不是实时的

问题描述

在此处输入图像描述

主要是做这张图片所做的但是我仍然卡在这里在此处输入图像描述

标签: python

解决方案


您以错误的方式输入货币。替换为以下代码:

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)

    

推荐阅读