Thus spake Ivan Shevanski ([EMAIL PROTECTED]): > Alright this is kind of a continuation of a past conversation. . .But not > really. Anyway, heres the problem. Say I had this: > > try: > x = input("> ") > except SyntaxError: > print "explain the problem here" > x = input("> ") > > That's to catch when people just press enter by mistake without selecting > something from the menu. But the thing is how would I make that loop? I > want it to keep catching the user pressing enter if they did it over and > over [there are some weird people out there ;)] I tryed this but to no > avail: > > try: > x = input("> ") > except SyntaxError: > while SyntaxError: > print "Please enter only the number beside your choice" > print > x = input("> ")
Well, leaving aside the merits of using "input" (which should be avoided at all costs), here's one way to do what you want: while 1: try: x = input("> ") break except SyntaxError: print "explain the problem here" Cheers, Aldo -- Aldo Cortesi [EMAIL PROTECTED] http://www.nullcube.com Mob: 0419 492 863 -- http://mail.python.org/mailman/listinfo/python-list