Below is my code to calculate calories based on input, after the print statements I want to exit the code and loop infinitely until the user inputs the right values.
import sys
def main():
while True:
try:
print("Please enter Age,Weight,Heart Rate and Workout Time ")
Age,Weight,HR,Time = map(eval,input().split(' '))
men = ( (Age * 0.2017) - (Weight * 0.09036) + (HR * 0.6309) - 55.0969 ) * Time / 4.184
women = ( (Age * 0.074) - (Weight * 0.05741) + (HR * 0.4472) - 20.4022 ) * Time / 4.184
print("Men:",men," Calories \nWomen:",women,"Calories \n")
exit()
except:
print("Please enter numbers only \n \n")
if __name__ == '__main__':
main()
The code goes to the except even if the input values are right and does not exit the code, what am I missing?