When i press 5 for quit it comes up as an error but does not work
For some reason
import sys
sys.exit()
does not work
def ask (user) :
if user == 1:
user = input('select a file with an ASCII art image ')
f = open(user, 'r')
if f.mode == 'r':
showart = f.read()
print(showart)
print("You will be returned to the menu")
elif user == 2:
print('hi')
elif user == 3:
print ('hi')
elif user == 4:
print("hi")
elif user == 5:
print('goodbye')
import sys
sys.exit()
while (True) :
print("1 - Display ASCII art ")
print("4 - convert RLE option ")
print("5 - Quit ")
print(" ")
print(" ")
print(" ")
try:
user=int(input("Select an integer between 1 and 5 : "))
if (user<5 and user > 1) :
ask(user)
else:
user=int(input("Please enter a number between 1 and 5 : "))
while (user > 5 or user < 1) :
user=int(input("Please enter a number between 1 and 5 : "))
ask (user)
except:
print('***SORRY, YOUR OPTION DID NOT WORK***\n ***PLEASE SELECT ANOTHER NUMBER***')
it prints goodbye but it does not quit the program