Hello! I posted the wrong question earlier, correct it again, and upload the question.
I'm working on a program that calculates BMI and BMR in Python As you can see in the picture, there are options from 1 to 4. (Please don't worry about the wrong number of entries between 3 and 4 in the middle menu!) If the user presses the wrong option, I want to mark it as Invalid and return to the option.
I would appreciate it if you could tell me how to code. I've been learning Python for about two weeks, so there are many things I don't know. ㅠ<
+) Modify and upload the code. There are many things I don't know because I'm posting my first question. I'm sorry for the immature question.
def inputDetails():
print("Introduction and Welcome Message\n")
print("Please input your details below : ")
user_name = input("Name : ")
user_birthday = input("Year of birth (YYYY) : ")
user_gender = input("Gender [F/M] : ")
weight = eval(input("Weight (kg) : "))
height = eval(input("Height (m) : "))
def menu():
print("\nChoose your option below:")
print ("1 - Body Mass Index (BMI) Calculator")
print ("2 - Basal Metabolic Rate (BMR) Calculator")
print ("3 - Weight Management")
print ("4 - Reset user details")
print ("Q/q - Quit")
choice = input("Your choice? ")
if choice == "1":
bmiCalculator()
elif choice == "2":
bmr()
elif choice == "q, Q":
exit()
else :
print("\nInvalid Choice! Please select from the list of choices.\n")
inputDetails()
menu()
You can repeat it indefinitely with while True in the def menu,
When calling the menu() itself
while True: menu()
This is how the menu () itself operates indefinitely.
783 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
557 GDB gets version error when attempting to debug with the Presense SDK (IDE)
555 Who developed the "avformat-59.dll" that comes with FFmpeg?
555 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.