Improved Choice

[Back] <- - + - -> [Next]

The keyword elif is a combination of else and if.
It can only follow after an if.
Each of the if and elif tests are applied in turn until one is True.
When one of the tests evaluates to True, all the later tests are ignored.
# previous code
if option == 'a':
    print 'You selected "a"'
elif option == 'b':
    print 'You selected "b"'

Running the code produces this output:
a AAA
b BBB
c CCC

Enter your choice: b
You selected "b"
   
The menu responds correctly
to either 'a' or 'b'.

If an 'a' is entered
the test for 'b' is ignored.