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

Alan Gauld alan.gauld at btinternet.com
Mon Oct 31 23:04:25 CET 2011


On 31/10/11 20:22, Peter Otten wrote:
> Alan Gauld wrote:
>
>> if choice.lower() not in ('prs'): # NB use a single string
>
> That's not a good idea. If a user accidentally enters PR (for example) your
> version will mistake that for a valid choice.

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

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


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



More information about the Tutor mailing list