[Tutor] Help with function scoping
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Mar 23 08:38:55 EDT 2017
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')
> userGuess = getUser()
One tiny tweak would be to remove the userGuess = getUser()
lines from the if/elif structure and just have a single
assignment at the end of the loop. It just saves
duplication and so means less work if you ever have
to change that line.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list