So I am making a program that takes kilometers and converts it to miles and then the other way around as well. When the program runs, the user is first prompted to enter either the number 1 or 2 to determine whether its kilo to miles or miles to kilo. If a user inputs anything other than a 1 or 2 I want to program to display "Please enter either the value 1 or 2" etc. and then ask again. What are some ways of doing that? Here is my code so far.
#Program that takes kilometers and converts it to miles VV
def main():
choice = input("Kilometers to Miles/Miles to Kilometers? (1, 2): ")
if choice == 1:
kilo = float(input("How many kilometers will you be traveling?: "))
convert = 0.62
miles = kilo * convert
print("You will be traveling about", miles, "miles!")
else:
milesTraveled = eval(input("How many miles will you be traveling?: "))
convertTwo = milesTraveled // 0.62
print("You will be traveling about", convertTwo, "kilometers!")
#end main
main()