| Store | Cart

Re: [Tutor] Help with function scoping

From: Alan Gauld via Tutor <tut...@python.org>
Thu, 23 Mar 2017 12:38:55 +0000
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


_______________________________________________
Tutor maillist  -  Tut...@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Recent Messages in this Thread
Richard Mcewan Mar 23, 2017 10:15 am
Alan Gauld via Tutor Mar 23, 2017 12:38 pm
Messages in this thread