How about doing it this way: def is_yes(question): yn = { 'y':True, 'yes':True, 'n':False, 'no':False } while True: try: return yn[raw_input(question).lower().strip()] except KeyError: print '\nplease select y, n, yes, or no\n'