[Tutor] Tutor Digest, Vol 92, Issue 127
Asokan Pichai
pasokan at talentsprint.com
Mon Oct 31 16:59:47 CET 2011
> From: Joel Montes de Oca <joelmontes01 at gmail.com>
> To: Tutor Python <tutor at python.org>
> Subject: [Tutor] Paper Rock Scissors game - User's choice not returned
> properly
> Message-ID: <4EAEC191.3060208 at gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
>
> Hello everyone,
>
>
> The function: ( http://dpaste.com/644857/)
>
> def UserChoice (): # The function that returns the choice from the
> user
> print 'Please select (P) for paper, (R) for Rock, or (S) for
> Scissors.'
> choice = raw_input('What is your selection?:')
>
> if choice.lower() not in ('p', 'r','s'): # Converts the
> user's choice to lowercase and confirms the choice is valid
> print 'I am sorry, you entered\'' + choice.upper() +
> '\' which is an invalid response. Please try again.'
> raw_input('Press Enter to try again.')
>
UserChoice () # If the choice is not valid, run
> the function over
>
You should use
return UserChoice()
> else:
> return choice
>
>
Asokan Pichai
SVP - Learning and Development
“Faith consists in believing when it is beyond the power of reason to
believe. "
Voltaire <http://www.brainyquote.com/quotes/quotes/v/voltaire163832.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111031/fbd05207/attachment.html>
More information about the Tutor
mailing list