[Tutor] (no subject)
fleet@teachout.org
fleet@teachout.org
Sun Nov 17 22:20:35 2002
> Why not:
>
> def get_name(prompt):
> return raw_input(prompt)
>
> while 1:
> opt = getnum()
> if opt == 1:
> s_name = get_name("Surname: ")
> elif opt == 2:
> g_name = get_name("Given Name: ")
> elif opt == 3:
> n_name = get_name("Nickname: ")
> else:
> break
>
> Note that this will break out of the while loop if any number other than
> 1, 2, or 3 is entered. That may not be what you want.
I'll try the function, thanks. I'm not sure I see an advantage. The
"else: break" would work fine; although it makes the prompt a little
wordy.
Regards,
- fleet -