Hi All
cannot figure out why my basic programme is not returning to main menu, from option 1 BMI figures. it takes me to option 2 menu for some reason. Does anyone see the quick fix to this issue?
Here is the code I did up:
def menu():
print("[1] Calculate body mass index BMI")
print("[2] Veiw membership cost")
print("[0] Exit the program.")
menu()
option = int(input("Please enter your option: "))
while option != 0:
if option == 1:
Height = float(input('Please enter your height in meters: '))
Weight = float(input('Please enter your weight in kilograms: '))
def BMI(Height, Weight):
BMI = round(Weight/(Height**2),3)
if (BMI < 18.5):
return 'Underweight', BMI
elif (BMI >= 18.5 and BMI < 25):
return 'Normal', BMI
elif (BMI >= 25 and BMI < 30):
return 'Overweight', BMI
elif (BMI >= 30):
return 'Obese', BMI
quote, BMI = BMI(Height, Weight)
print('Your BMI is: {} and you are: {}'.format(BMI, quote))
anykey=input("Enter any key to return to main menu: ")
menu()
elif option == 2:
def package():
print("[1] Our BASIC membership package")
print("[2] Our REGULAR membership package")
print("[3] Our PREMIUM membership package")
print("[4] Return to MAIN menu")
print("[5] Exit the programme")
while True:
package()
option = int(input("Please enter your option: "))
if option == 1:
print("Our BASIC membership cost is $10 per week")
base_weekly_cost = 10
base_weekly_cost = base_weekly_cost * 4
print("The monthly cost will be, $" + str(base_weekly_cost))
elif option == 2:
print("Our REGULAR membership cost is $15 per week")
base_weekly_cost = 15
base_weekly_cost = base_weekly_cost * 4
print("The monthly cost will be, $" + str(base_weekly_cost))
elif option == 3:
print("Our PREMIUM membership plan costs $20 per week")
base_weekly_cost = 20
base_weekly_cost = base_weekly_cost * 4
print("The monthly cost will be, $" + str(base_weekly_cost))
elif option == 4:
print("Hold on 2 seconds, returning you to the MAIN menu......")
menu()
break
elif option == 5:
print("Thank you for using my menu programme.")
quit()
else:
print("Invalid option, please select 0 to 3")
anykey=input("Enter any key to return to membership menu: ")
package()
else:
print("Invalid option, please select 0 to 2")
print()
menu()
option = int(input("Please enter your option: "))
print("Thank you for using my menu programme.")
“”"