[Tutor] (no subject)

boB Stepp robertvstepp at gmail.com
Thu Aug 3 23:47:19 EDT 2017


Greetings Howard!

On Thu, Aug 3, 2017 at 3:27 PM, Howard Lawrence <1019shaun at gmail.com> wrote:
> hi ! i am newbie to coding love it but need help with problems which i
> searched but poor results this is the error: typeError unorderable types:
> int()<str()
> the code in short, number=random.randint(1,20)
> guess=input()
> guess=int(guess)
> but when reach the line that says
> if guess<number:
>
> i get the error ! help

With the code snippets you've shown in the order you have shown them,
I would not expect you to get this error as it appears that you have
converted the string values from your input statements into integers.
But I suspect that you have not shown the part of the code that is
generating the error.

When posting to this list (Or any other coding list for that matter.)
you should always *copy and paste* into your plain text email the
actual code giving the error.  And then *copy and paste* the FULL
error traceback you receive.  And it does not hurt to give the python
version you are using and the operating system on your machine, too.

At this point I can only guess at things.  Since apparently this is a
number guessing game, you probably have a while loop. Did you use your
variable "guess" in the while statement's condition *before*
converting it to an integer?

Somewhere in your code you are checking that an integer is less than a
string, which is not doable.  The error traceback should tell you what
line number to start looking.

If this does not help then you need to resend your message with your
full code and full traceback unless someone else has better oracle
abilities... ~(:>))



-- 
boB


More information about the Tutor mailing list