On 29/08/15 22:37, Martin Mwaka wrote:
myNumber = input("Input a number between 1 and 5: ")
myNumber is now a *string* representing a number from 1-5.
while computerNumber != 0:
if myNumber != computerNumber:
computerNumber = random.randint(1,5)
computerNumber is now a random *integer* between 1-5
A string can never equal an integer. "5" is not the same as 5
Types are important in programming.
print ("Your chosen number is ", myNumber,": Computer number is: ",
computerNumber)
else:
So the else will never get called
You need to convert your string into an integer using int()
myNumber = int(input("Input a number between 1 and 5: "))
HTH
--
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 - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor