Day 018 - Project 18 : Guess the Number

If you have any questions, comments or issues with this project please post them here!

Hi Ian! I’m currently scratching my head at this error that python is throwing at me.
the error is " type error: “>=” not supported between instances of ‘int’ and ‘str’. here’s part of my code:

print (“guess the number challenge”)
print()
count1 = 0
while True:
print (“pick a number between 0 and 100”)
number = int(input("what is your guess? > "))
print()
if number >= “90” and number <= “100”:
print (“too high”)
count1 += 1
continue
print()
elif number >= “80” and number <= “89”:
print (“still too high”)
count1 += 1
continue
print ()

The error is as the message states, Python cannot tell if a string is greater than or less than an integer.
Hence, this will cause an error:

if 1 > "1":

You will need to do:

if 1 > 1:

Your code should probably look like this:

print("guess the number challenge")
print()
count1 = 0
while True:
	print ("pick a number between 0 and 100")
	number = int(input("what is your guess? > "))
	print()
	if number >= 90 and number <= 100:
		print ("too high")
		count1 += 1
		continue
	elif number >= 80 and number <= 89:
		print ("still too high")
		count1 += 1
		continue

By adding quotation marks (") to the numbers you are comparing, you made them strings.

3 Likes

omg thank you so much!

1 Like

@MattDESTROYER it’s past midnight and i think my brain is partly fried but thank you again! the program works as expected now

I would suggest getting some sleep then, it’s 11:30am on a Sunday for me lol.

1 Like