def handleInt(cmd): try: cmd + 10 except TypeError, (error,): cmdHandler(cmd) if(cmd <= 31): states['day']= cmd else: print 'Invalid day' def handleInt(cmd): try: cmd + 10 #what is this for? except TypeError: cmdHandler(cmd) if int(cmd) <= 31: states['day']= cmd else: print 'Invalid day'