I'm building a currency converter and I've pretty much finished the program. However, I am trying to eliminate redundancy by implementing a function or a define block. I've tried a number of things but it does not seem to be working.
My current code is like this:
EUR = 0.83
EGY = 16.22
def currency_converter():
money = total_value
new_value = 0
if currency == 1:
new_value = money*EUR_CON
print("Your total is " + "$" + str(money) + " US Dollars which is " + "e£ " + str(new_value) + " European Euros.")
elif currency == 2:
new_value = money*EGY_CON
print("Your total is " + "$" + str(money) + " US Dollars which is " + "e£ " + str(new_value) + " Egyptian Pounds.")
I want to essentially make the clause under the if
/elif
block a function. I've tried doing this:
def conversion(EUR_CON,GDP_CON, BRL_CON, EGY_CON, YEN_CON):
new_value = money*conversion()
print("Your total is " + "$" + str(money) + " US Dollars which is " + str(new_value)+ str(conversion)
if currency == 1:
conversion(EURO_CON)
But it's not working. Can someone help?