#!/usr/bin/env python3
import sys


def exit():
    input('Press <Enter> to exit')
    sys.exit()


def expect_digits():
    options = {'4': exit}
    for d in '123':
        options[d] = lambda d=d: print(d)
    expect(options)


def expect(options):
    while True:
        answer = input('Input ' + '|'.join(options)).strip()
        if answer in options:
            options[answer]()
        else:
            print('Unknown command. Try again')


expect({'y': expect_digits, 'n': exit})