I want the user to provide input for a program such that if the user gives the wrong input the code should prompt them to enter a correct value.
I tried this code but because of the continue
statements it runs the loop from the very start. I want the code to return to its respective try block. Please help.
def boiler():
while True:
try:
capacity =float(input("Capacity of Boiler:"))
except:
print ("Enter correct value!!")
continue
try:
steam_temp =float(input("Operating Steam Temperature:"))
except:
print ("Enter correct value!!")
continue
try:
steam_pre =float(input("Operating Steam Pressure:"))
except:
print ("Enter correct value!!")
continue
try:
enthalpy =float(input("Enthalpy:"))
except:
print ("Enter correct value!!")
continue
else:
break
boiler()