Quote (normannen @ Jul 10 2015 01:11pm)
elif choice == "E":
print("Thank you for using our program")
break
this does not work to end the while loop, i cannot use an if loop because it only runs once if i use if choice != E: main()
for some reason choice is not translating to E at the end. because if choice == E right now, it should end the loop, which is what i dont understand
i had the choice designation in the wrong place thats all, it needed to be in the loop instead of in the main, this is how i fixed it.
Code
choice = ""
def welcome():
print ("Welcome to the Metric Conversion Program\nThis program will take a unit of measurement and convert\nit to degrees Celcius or Meters.\n**********************************************************")
def choices(choice):
choice = ""
choice = str(input("Here are your choices:\n\tC for Celcius\n\tM for Meters\n\tE for Exit"))
Fahrenheit = 0.0
Celcius = 0.0
Feet = 0.0
Meters = 0.0
if choice == "C":
Celcius = fahrenheit_to_celcius(Fahrenheit,Celcius)
print (Celcius)
elif choice == "M":
Meters = feet_to_meters(Feet,Meters)
print (Meters)
elif choice == "E":
print("Thank you for using our program")
else:
print("Sorry you did not enter a C, M or E\nPlease try again: ")
choices(choice)
return choice
def fahrenheit_to_celcius(Fahrenheit,Celcius):
Fahrenheit = 0.0
Celcius = 0.0
Fahrenheit = float(input("Enter Degrees Fahrenheit: "))
Celcius = (5/9)*(Fahrenheit-32)
return Celcius
def feet_to_meters(Feet,Meters):
Feet = 0.0
Meters = 0.0
Feet = float(input("Enter Feet: "))
Meters = (0.305*Feet)
return Meters
def main():
choice = ""
Feet = 0.0
Meters = 0.0
Fahrenheit = 0.0
Celcius = 0.0
welcome()
while choice != "E":
main()
choice = choices(choice)
This post was edited by Drakwen on Jul 10 2015 12:25pm