lundi 26 juin 2017

Greater than and Less than not working correctly with random number in Python [duplicate]

This question already has an answer here:

I am working on a project that involves random numbers and them being greater or less than another number.

from random import randint number = (randint(0, 100)) guess = raw_input("Guess: ") print number if (guess > number): print str(guess) + " is greater than "+ str(number)

This code was created to help me debug my problem, but nothing worked. No matter what I put in as the variable "guess," it would always say that it was larger than the random number.

For example:
Guess: 0
27
0 is greater than 27.

Is this a problem with my code or with the random numbers? Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire