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 y
It looks like you are confusing variable names with variables. Because the currency type you get from the user is a string, it can't be used to reference variables unless you call eval on it.
new_amount = eval(future_currency) * amount
The downside of this is that using eval
gives the user a possible way to affect your code. Instead, you can use a dictionary. Dictionaries map strings to values, and so you can take your variable declarations:
yen = 0.0067
bsp = 1.35
usd = 0.65
ero = 0.85
And turn them into a dictionary:
currencies = {'yen': 0.0067, 'bsp': 1.35, 'usd': 0.65, 'ero': 0.85}
Using this, you can find the value you are looking for in the dictionary. Don't forget to handle incorrect user input properly!
currencies = {'yen': 0.0067, 'bsp': 1.35, 'usd': 0.65, 'ero': 0.85}
current_currency = raw_input()
future_currency = raw_input()
amount = int(raw_input())
// Check for errors in input here
new_amount = amount * currencies[future_currency] / currencies[current_currency]