Python Forum

Full Version: Python TypeError?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
from random import randint
CorrectNumber = (1,20)
while True:
GuessedNumber = int(input("Guess a number between 1-20! "))
if GuessedNumber == CorrectNumber:
print("Correct, You Guessed the Number!")
break
elif GuessedNumber < CorrectNumber:
print("Too Low!")
continue
elif GuessedNumber > CorrectNumber:
print("Too High!")
continue
print("You Win!")


I am trying to make this guessing game, and i was attempting to improve it but now it says there is a TypeError in line 8,

Traceback (most recent call last):
File "<string>", line 8, in <module>
TypeError: unorderable types: int() < tuple()
Please use python tags when posting code. See the BBCode link in my signature below for instructions.

CorrectNumber is not a number, it's a tuple of two numbers. You can't compare a tuple to a single number. I'm assuming you want to generate a random number, so line 2 should instead be:

CorrectNumber = randint(1, 20)
Yea i figured that out, lol I didn't see that i missed randint lol
Dear Sir,
I am getting "'float' object is not callable (source id=1:0)" line 5 of the code. the code is posted below.

def _compute_distance(cls, rup, dists, alpha4_rrup, alpha4_sqrt_rrup, coeffs, ro2):
dist=0.0
for idist in xrange(len(alpha4_rrup)):
print alpha4_rrup[idist]
dist += coeffs['alpha3'](idist)*np.log(expi(alpha4_rrup(idist))-expi(alpha4_sqrt_rrup(idist)))/ro2
return dist