On 01/11/11 09:46, Peter Otten wrote:
Alan Gauld wrote:

Good point, although  you could test the first character only...

if choice[0].lower() not in ('prs'): # NB use a single string

What Steven says, plus you may run into an IndexError if choice is the empty
string. If you absolutely want to test against a single string you have to
check the length first.

Hmm, yeah, ok you win :-)

Use the list form, even though it does involve a few more keystrokes and a lot more screen space. The extra typing to avoid the problems are not worth it! :-)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to