[Tutor] Paper Rock Scissors game - User's choice not returned properly

Alan Gauld alan.gauld at btinternet.com
Tue Nov 1 19:14:20 CET 2011

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

More information about the Tutor mailing list