Will Trotter
Will Trotter

Reputation: 1

comparing two lists creates an error

I'm trying to make the program print smaller numbers than it did previously this error doesnt make any sense as im comparing two lists not an int and a list?

    else:
        if len(tuple(guessstore)) == 3:
            if guessstore[1] > code[1]:    
                randomnumber2 = random.randint(0,9 < guessstore[1])
            elif guessstore[1] < code[1]:    
                randomnumber2 = random.randint(0,9 > guessstore[1])

Traceback (most recent call last):
  File "F:\Further Programming\Assignment3\number2.py", line 153, in <module>
    ch2()
  File "F:\Further Programming\Assignment3\number2.py", line 82, in ch2
    if guessstore[1] > code[1]:    #if code is larger than guess print that its larger
TypeError: unorderable types: list() > int()

Please help. I don't know why I'm getting this error

Upvotes: 0

Views: 25

Answers (1)

Copperfield
Copperfield

Reputation: 8510

looks like guessstore[1] is a list and code[1] is a int, maybe the error is in how you handle guessstore that make it a list of list, by the code you show, looks like guessstore is a list, if that is the case perhaps you do something like this guessstore+=[[n]] or guessstore.append( [n] ) (where n in a number) that make you guard a list with n in it inside of guessstore, instead do guessstore.append( n ). Or equivalently in how you handle code that make it a list of int, with only that portion of the code that is all of what I can tell.

Upvotes: 1

Related Questions