So I just wrote a basic mile to km converter on python3. It asks you If you want to convert nautical miles or land miles into km when you type nautical it goes to that loop and converts nautical miles to km. The same thing goes with land, if you type land it converts land miles into km. But the problem is when I type something else than nautical or land the program just crashes. How can I write the code that says "Please only write nautical or land in this input".And when I type a input that is not a number in the "how many miles do you want to convert in km part" the same thing happens and it crashes...
print("Hello! This is a mile to km converter")
print("Do you want to convert nauitcal miles or land miles?")
question_convert = input("Please type nautical or land \n")
if question_convert == "nautical":
NAUTICAL = True
if question_convert == "land":
NAUTICAL = False
while True:
while NAUTICAL == True:
nautical_mile = 1.852
print("How many nauitical miles do you want to convert in km?")
convert_nauitcal = float(input())
converted_nautical = float(convert_nauitcal * nautical_mile)
print("Here's your converted nauitical miles: ")
print(converted_nautical)
quit()
while NAUTICAL == False:
land_mile = 1.609344
print("How many land miles do you want to convert in km?")
convert_land = float(input())
converted_land = float(convert_land * land_mile)
print("Here's your converted land miles: ")
print(converted_land)
quit()
#land_mile = 1.609344
#nautical_mile = 1.852