[Tutor] unorderable types
Alan Gauld
alan.gauld at yahoo.co.uk
Sun Aug 6 02:19:25 EDT 2017
On 05/08/17 19:28, Howard Lawrence wrote:
> if guess_value != number:
> number = str(number)
> print ('nope. the number i was thinking of was ' + number)
There is the problem, you convert number to a str before printing
it. so next iteration of the loop your if test fails.
You don't need the conversion in this case because print does it
automatically. If you did need it for some other purpose then
you should store the result in a temp variable rather than
in number itself.
This is a good example of why you should post the whole of your
code not just the snippet that you think is causing the problem...
If you had posted this in the first message we would probably
have spotted it right away.
--
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