As described in the title, I am unable to break out of the python (while) loop, and unsure why?
def display_menu(gbook):
"""
"""
print("")
print("Please choose an option below:")
print("")
print("1. Record a grade")
print("2. Print all grades")
print("3. Calculate GPA")
print("4. Exit")
print("_________________________________________")
while True:
print("")
choice = input("Please select a numbered option from above")
if re.match(r'^\d+$', choice):
choice = int(choice)
if choice in [1, 2, 3, 4]:
break
if choice == "1":
record_grade(gbook)
elif choice == "2":
print_grades(gbook)
elif choice == "3":
calculate_gpa(gbook)
elif choice == "4":
exit()
else:
print("Invalid choice. Please try again.")
I was expecting once the proper entry was made, that I would be broken out of the loop.