Re: [Tutor] Help with function scoping

2017-03-23 Thread Alan Gauld via Tutor
On 23/03/17 10:15, Richard Mcewan wrote: > #loop to check guess and report > while userGuess != computerGuess: > if userGuess < computerGuess: > print('Too low') > userGuess = getUser() > elif userGuess > computerGuess: > print('Too high') >

[Tutor] Help with function scoping

2017-03-23 Thread Richard Mcewan
Hi Thanks Mats, Joel and Alan for helpful advice. This code (below) behaves as I wanted now. And think I see where I was going wrong with functions. Thank you very much. Richard Ps I'll reflect on appropriate variable names also. # coding: utf-8 import random #guess number game #compute

Re: [Tutor] Help with function scoping

2017-03-23 Thread Mats Wichmann
On 03/22/2017 03:17 PM, Richard Mcewan wrote: > Hi > > I wonder if you can help. > > I'm confused about how functions should work. Below is some code I write to > check my understanding. > > I'm expecting two functions to be defined. Then called. One returns a random > number. The other user

Re: [Tutor] Help with function scoping

2017-03-22 Thread Alan Gauld via Tutor
On 22/03/17 21:17, Richard Mcewan wrote: > I'm expecting two functions to be defined. Then called. And thats what you've got. But... > One returns a random number. The other user input (guessing the number). And thats also what you've got but you don't do anything with the returned value you

Re: [Tutor] Help with function scoping

2017-03-22 Thread Joel Goldstick
On Wed, Mar 22, 2017 at 5:17 PM, Richard Mcewan wrote: > Hi > > I wonder if you can help. > > I'm confused about how functions should work. Below is some code I write to > check my understanding. > > I'm expecting two functions to be defined. Then called. One returns a random > number. The other

[Tutor] Help with function scoping

2017-03-22 Thread Richard Mcewan
Hi I wonder if you can help. I'm confused about how functions should work. Below is some code I write to check my understanding. I'm expecting two functions to be defined. Then called. One returns a random number. The other user input (guessing the number). I expect the return values to ac