Python Forum

Full Version: '<' not supported between instances of 'str' and 'int'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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's the number from 1 to 99..and I'll give you 6 chances")

while guess != secret and tries < 6:
    guess = input("What's your guess? ")
    if guess < secret:
        print("To Low...You creep")

    elif guess > secret:
        print("Too High, Douchbag")
        tries = tries + 1

        if guess == secret:
            print("Avast! You finally got it!")

        else:
            print("No more chances...Play again later")
            print("The secret number was", secret)
input returns string and therefore you comparing string with int which for quite obvious reasons is not possible. You should convert input to int.