简体   繁体   中英

Python- Currency converter not real time

在此处输入图像描述

the main thing is to do what this image did however im still stuck here在此处输入图像描述

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)

    

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM