-5
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 = currencies[Future_Currency] / currencies[Current_Currency] * amount

我该如何解决?

4

1 回答 1

1

amount是一个字符串,因为input()返回字符串。首先将其转换为数字,方法是通过数字类型的构造函数运行它。

amount = float(amount)
于 2013-08-16T10:26:12.330 回答