[Tutor] Engarde program was: i++

Eric Evenson evenson at gmail.com
Thu Jun 7 20:33:17 CEST 2007


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'


More information about the Tutor mailing list