Hi All
I have nearly completed this assignment, but I am stuck on why the menu is now asking me to enter my responses twice!! grrrr…I am just a beginner, so sorry for the painful questions. This is the error below:: Can someone help me fix this last part!
Welcome to City Gym main menu
[1] Calculate body mass index BMI
[2] Veiw membership cost
[0] Exit the program.
Please enter your option: 1
Please enter your option:
Here is my code:
import time
def menu():
print("***Welcome to City Gym main menu***")
print()
print("[1] Calculate body mass index BMI")
print("[2] Veiw membership cost")
print("[0] Exit the program.")
menu()
try:
option = int(input("Please enter your option: "))
except ValueError:
print("Invalid Entry, you MUST enter a number, please select 0 to 2")
option = int(input("Please enter your option: "))
time.sleep(1)
while option != 0:
if option == 1:
Height = float(input('Please enter your height in meters: '))
print("Processing...")
time.sleep(1)
Weight = float(input('Please enter your weight in kilograms: '))
print("Processing...")
time.sleep(1)
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: ")
print()
menu()
elif option == 2:
def package():
print()
print("***Welcome to City Gyms Member page***")
print()
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()
try:
option = int(input("Please enter your option: "))
except ValueError:
print("Invalid Entry, you MUST enter a number, please select 1 to 5")
option = int(input("Please enter your option: "))
print("Processing...")
time.sleep(1)
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 5")
anykey=input("Enter any key to return to membership menu: ")
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.")