[Tutor] loop raw input

bob gailer bgailer at gmail.com
Fri May 21 19:48:39 CEST 2010


On 5/21/2010 5:35 AM, Norman Khine wrote:
> hello,
> i have this script, but i am stuck at the loop, if the user types an
> incorrect database id:
>
> http://paste.lisp.org/+25D3
>
> how would i write the exception correctly?
>    

Which line of code could raise the ValueError exception?

That line should be in the try block.

I also suggest unique error messages. If the user does not enter a 
number tell him so.

Also you need a way to break out of the loop once user enters a valid key.

Consider using the isdigit function to test the input instead of an 
exception.

-- 
Bob Gailer
919-636-4239
Chapel Hill NC



More information about the Tutor mailing list