I'm new to learning python and creating a basic program to convert units of measurement which I will eventually expand upon but im trying to figure out how to loop the entire program. When I insert a while loop it only loops the first 2 lines. Can someone provide a detailed beginner friendly explanation. Here is my program.
#!/usr/bin/env python
restart = "true"
while restart == "true":
#Program starts here
print "To start the Unit Converter please type the number next tothe conversion you would like to perform"
choice = input("\n1:Inches to Meter\n2:Millileters to Pint\n3:Acres to Square-Miles\n")
#If user enters 1
rogram converts inches to meters
if choice == 1:
number = int(raw_input("\n\nType the amount in Inches you would like to convert to Meters.\n"))
operation = "Inches to Meters"
calc = round(number * .0254, 2)
print "\n",number,"Inches =",calc,"Meters"
restart = raw_input("If you would like to perform another conversion type: true\n"
#If user enters 2
rogram converts millimeters to pints
elif choice == 2:
number = int(raw_input("\n\nType the amount in Milliliters you would like to convert to Pints.\n"))
operation = "Milliliters to Pints"
calc = round(number * 0.0021134,2)
print "\n",number,"Milliliters =",calc,"Pints"
restart = raw_input("If you would like to perform another conversion type: true\n")
#If user enter 3
rogram converts kilometers to miles
elif choice == 3:
number = int(raw_input("\n\nType the amount in Kilometers you would like to convert to Miles.\n"))
operation = "Kilometers to Miles"
calc = round(number * 0.62137,2)
print "\n",number,"Kilometers =",calc,"Miles"
restart = raw_input("If you would like to perform another conversion type: true\n")