[Tutor] Paper Rock Scissors game - User's choice not returned properly
__peter__ at web.de
Tue Nov 1 10:46:20 CET 2011
Alan Gauld wrote:
> 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.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.
More information about the Tutor