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

Alan Gauld alan.gauld at btinternet.com
Mon Oct 31 19:46:57 CET 2011

On 31/10/11 17:09, Joel Montes de Oca wrote:

>    |
>    |
>    |__ FUN A
>            |
>            |
>            |_ FUN B
> This is how I understand it. So if I want this to work, I need FUN B to
> give something back to FUN A so that FUN A will have something to give
> back to FUN MAIN but that doesn't feel right.

It is right. You need to add a return statement to your code like so:

def UserChoice ():	
	if choice.lower() not in ('prs'): # NB use a single string
		raw_input('Press Enter to try again.')
		return UserChoice ()   # must return the value to caller
		return choice    # just as you do here

But this is not the best way to use recursion...

> Is there a way to say GO TO FUN A instead of calling the function?

Yes, in a while loop. As a later post shows you figured  out!
That's a much better solution. But this shows that you could have used 
recursion if you really wanted to.


Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list