[Tutor] Help with scoping

2017-03-23 Thread Richard Mcewan
Hi Thanks Alan and all. I've incorporated your points. I've explored how values are returned and used by functions. I switched to Python to check a Swift3 bug and I think I can see a number of issues more clearly now. I put the count and call for next user guess back a tab at the end of the

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] Using Class Properly - early beginner question

2017-03-23 Thread Alan Gauld via Tutor
On 22/03/17 12:30, Rafael Knuth wrote: > I wrote a function that does exactly what I want, and that is: > Create a shopping list and then let the user decide which items (food) > are supposed to be instantly consumed and which ones stored. That's a good start, because it means you understand your

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] Using Class Properly - early beginner question

2017-03-23 Thread Mats Wichmann
On 03/22/2017 06:30 AM, Rafael Knuth wrote: > thanks for your feedback! @boB > > I wrote a function that does exactly what I want, and that is: > Create a shopping list and then let the user decide which items (food) > are supposed to be instantly consumed and which ones stored. > > def ManageFoo