Loop exception catching

Ivan Shevanski darkpaladin79 at gmail.com
Mon Jan 23 23:03:26 CET 2006


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("> ")


. . .Any suggestions?




Thanks in advance,

-Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060123/0f597557/attachment.html>


More information about the Python-list mailing list