On Mon 31 Oct 2011 11:59:47 AM EDT, Asokan Pichai wrote:

    From: Joel Montes de Oca <[email protected]
    <mailto:[email protected]>>
    To: Tutor Python <[email protected] <mailto:[email protected]>>
    Subject: [Tutor] Paper Rock Scissors game - User's choice not returned
           properly
    Message-ID: <[email protected]
    <mailto:[email protected]>>
    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  -  [email protected]
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.
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to