The code seems to continue running even after inputting Q or q. I know we need to break it from the loop but when I keep it inside the main function the output seems to be both "Thank you for using the program!" "Invalid Input, Please Enter 1-2-Q for the desired action to be performed" when I enter Q
def main():
count = True
while count == True:
print("1 - Chemical formula for the Ionic Compound")
print("2 - Chemical Name for the Ionic Compound")
print("Q - EXIT")
print("-----------------------------------------------")
action = input("What action would you like to execute? ")
menu(action)
def menu(action):
if action == "1":
print()
e1 = input("Enter chemical symbol for first element: ")
c1 = int(input("Enter the first element charge: "))
e2 = input("Enter chemical symbol for second element: ")
c2 = int(input("Enter the second element charge: "))
print()
print(chemistry.ionicCompound(e1, c1, e2, c2))
elif action == "2":
print()
e1 = input("Enter chemical symbol for first element: ")
e2 = input("Enter chemical symbol for second element: ")
print(chemistry.ionicName(e1, e2))
elif action == "Q" or action == "q":
print()
print("Thank you for using the program!")
else:
print()
print("Invalid Input, Please Enter 1-2-Q for the desired action to be performed")
print()
print("----------------------------------------------------------------------------------")
main()