loop = 3 n = True while n: try: choice = int(raw_input('You choice: ')) except ValueError: print 'ERROR: "{0}" not integer'.format(choice) loop -= 1 else: if choice != 1 or choice != 2 or choice != 3 or choice != 4: print 'ERROR: "{0}" must be [1:4]'.format(choice) loop -= 1 else: if choice == 4: import sys print 'By by' sys.exit(1) n = False if loop == 0: import sys print 'By by' sys.exit(1)