I'm trying to make a very simple Python program that will convert USD to several different currencies. I am having trouble with an IF/ELIF statement. Whenever I run the code in my interpreter, in this case Pycharm, the interpreter will prompt me to input the value I want to convert, followed by the currency I want to convert to, and then finish without printing anything that I have set up in the IF/ELIF statement.
Code:
import os
os.system('cls')
# This code starts the program and explains
# the purpose of the program to the user.
print()
print("Hello User")
print("This program will convert dollars to yen.")
print()
# This code prompts the user to enter a dollar amount.
USD = input("Amount of dollars: ")
# This code converts the user entered amount as a floating
# point integer for ease of calculation and error correcting.
var1 = float(USD)
print("YEN: 1")
print("EUR: 2")
print("RUB: 3")
print("Yuan: 4")
var2 = input("What Currency Do You Want To Convert To?: ")
def my_converter():
if var2 == 1:
var3 = var1 * float(114.62)
var4 = "Yen"
print(USD, "U.S. Dollars equals", var3, var4)
elif var2 == 2:
var3 = var1 * float(1.14)
var4 = "Euro"
print(USD, "U.S. Dollars equals", var3, var4)
elif var2 == 3:
var3 = var1 * float(0.015)
var4 = "Rubles"
print(USD, "U.S. Dollars equals", var3, var4)
elif var2 == 4:
var3 = var1 * float(0.15)
var4 = "Yuan"
print(USD, "U.S. Dollars equals", var3, var4)
I am just getting into Python so I'm probably just missing something really obvious, but any help would be greatly appreciated. Apologies if this is a duplicate or dumb question.