[Tutor] Tutor Digest, Vol 92, Issue 127

Joel Montes de Oca joelmontes01 at gmail.com
Mon Oct 31 17:03:52 CET 2011


On Mon 31 Oct 2011 11:59:47 AM EDT, Asokan Pichai wrote:
>
>     From: Joel Montes de Oca <joelmontes01 at gmail.com
>     <mailto:joelmontes01 at gmail.com>>
>     To: Tutor Python <tutor at python.org <mailto:tutor at python.org>>
>     Subject: [Tutor] Paper Rock Scissors game - User's choice not returned
>            properly
>     Message-ID: <4EAEC191.3060208 at gmail.com
>     <mailto: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>
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

I am not sure if I understand, why doesn't my way work and what do you 
mean I should return UserChoice()?

-- 
-Joel M.


More information about the Tutor mailing list