python - unsupported operand type(s) for /: 'str' and 'str' pervious asked a q before answer got this -
currencies = {'yen': 0.0067, 'bsp': 1.35, 'usd': 0.65, 'ero': 0.85} if choice == "2": current_currency = input("what currency want exchange: japenese yen if please type yen // british sterling pound please type bsp // dollers please type usd // euro please type ero.") amount = input("type amount wish exchange") future_currency = input("what currency want exchange into: japenese yen if please type yen // british sterling pound please type bsp // dollers please type usd // euro please type ero.") new_amount = future_currency / current_currency * amount
honestly killing me need fixed last hurdle cant on big novice please keep language simple
both future_currency , current_currency strings, input. looks want use them keys dictionary of rates, follows:
new_amount = currencies[future_currency] / currencies[current_currency] * amount
or, split more lines readability:
future_value = currencies[future_currency] current_value = currencies[current_currency] ratio = future_value / current_value new_amount = ratio * amount
Comments
Post a Comment