currencies = {'yen': 0.0067, 'bsp': 1.35, 'usd': 0.65, 'ero': 0.85}
if choice == "2":
Current_Currency = input("What currency do you want to exchange: Japenese Yen if so please type yen // British Sterling Pound please type bsp // US Dollers please Type usd // Euro please type ero.")
amount = input("Type amount you wish to exchange")
Future_Currency = input("What currency do you want to exchange into: Japenese Yen if so please type yen // British Sterling Pound please type bsp // US Dollers please Type usd // Euro please type ero.")
New_Amount = Future_Currency / Current_Currency * amount
老实说这是杀了我,我只需要得到这个固定的最后障碍,我无法克服我是一个非常大的新手所以请保持语言简单
答案 0 :(得分:2)
Future_Currency和Current_Currency都是字符串,作为输入。看起来你想要的是将它们用作你的费率字典的键,如下所示:
New_Amount = currencies[Future_Currency] / currencies[Current_Currency] * amount
或者,为了便于阅读,分成更多行:
Future_Value = currencies[Future_Currency]
Current_Value = currencies[Current_Currency]
ratio = Future_Value / Current_Value
New_Amount = ratio * amount