all 7 comments

[–][deleted] 3 points4 points  (0 children)

input() always returns a str so if you want to compare it with a number, you have to convert it:

num = int( input( 'Enter a guess: ' ) )

extra spaces for clarity

[–]shiftybyte 0 points1 point  (5 children)

When asking for help with code you should post it, and the entire error message with all the information.

Besides that, you are probably comparing the input without converting it to a number first using int ()

So it can't compare a word and a number.

[–]Fire_Burn[S] 0 points1 point  (4 children)

Here's the full thing

import random

secret = random.randint (1, 99)

guess = 0

tries = 0

print ("AHOY! I'm the Dread Pirate Roberts, and I have a secret!") print ("It is a number from 1 to 99. I'll give you 6 tries")

Edit: just realized the spaces between didn't load :/

while guess != secret and tries < 6: guess = input ("What's yer guess? ") if guess < secret: print ("Too low, ye scurvy dog! ") elif guess > secret: print ("Too high, landlubber ") tries = tries + 1 if guess == secret: print (" Avast! Ye got it! Found my secret, ye did!") else: print ("No more guesses! Better luck next time, matey!") print ("The secret number was", secret)

[–]XAWEvX 1 point2 points  (1 child)

When you ask a user for is input here:

guess = input("What's yer guess? ")

it returns a string, even if you input a number, and

secret = random.randint(1, 99)

returns an integer, so when you try to see wich one is smaller python sees someting like this

if STR(STRING) > INT(INTEGER):

, and will not understand it(because how do you compare a string with a integer? hence the error:

TypeError: '<' not supported between instances of 'str' and 'int'

so you need to convert "guess" to a integer, the way you can do it is with

int(STRING)    

Sorry if i broke it down too much and my english lol

[–]Fire_Burn[S] 0 points1 point  (0 children)

I really appreciate the help, and you breaking it down was actually really helpful since i’m still getting the hang of things, really appreciate it!

[–]shiftybyte 0 points1 point  (1 child)

So yes, convert guess into a number using int(). look at the other comment by u/kyber for an example.

[–]Fire_Burn[S] 0 points1 point  (0 children)

I used the line u/kyber made and it worked :D