Exit Option
[Back] <- - + - -> [Next]
So that the user can select 'x' to exit from the menu program
add an extra option to the menu and an extra elif to break out of the loop.
while True:
# previous code
print 'c CCC'
print 'x Exit' ### Add an extra option to be displayed
# previous code
elif option == 'x': ### Add an extra test
break ### Immediately break out of the while loop
else:
print 'Invalid choice - try again'
The program can now be ended by entering 'x'.
Running the code produces this output:
:
Enter your choice: x
The cycle repeats until x is entered.