This is a function of a larger Python program. How can I get it to loop continuously until "4" is entered? Any help is greatly appreciated.
print("\nEnter a number (1) - (4). (4) terminates the program.")
choice = int(input("Enter your choice: "))
while((choice != 1) and (choice != 2) and (choice != 3) and (choice != 4)):
choice = int(input("\nInvalid option. Enter a number from the menu: "))
if(choice == 1):
f = open("dna1.txt", "r")
if f.mode == "r":
contents = f.read()
print("\nOriginal: {0}" .format(contents))
if(choice == 2):
f = open("dna2.txt", "r")
if f.mode == "r":
contents = f.read()
print("\nOriginal: {0}" .format(contents))
if(choice == 3):
f = open("dna3.txt", "r")
if f.mode == "r":
contents = f.read()
print("\nOriginal: {0}" .format(contents))
if(choice == 4):
print("Exiting program.")
sys.exit