[Tutor] (regarding unorderable types

Howard Lawrence 1019shaun at gmail.com
Fri Aug 4 07:11:06 EDT 2017


Thank you for the clarification.
as a newbie at mailing list and coding
I try to be more specific,their is more to come

On Aug 3, 2017 10:09 PM, "Cameron Simpson" <cs at cskk.id.au> wrote:

Hi, and welcome to the tutor list.

Please try to provide a useful subject line in future posts (not "help",
perhaps something like "I don't understand this TypeError message").

Anyway, to your question:

On 03Aug2017 13:27, 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()
>

Please always include the entire error message with a text cut/paste; it
usually contains lots of useful information.

The error above means that you have a "int" and a "str", and are trying to
compare them. That is not supported.

the code in short
>

Please always incode the full code, ideally something stripped down to the
smallest program you can run which still produces the error. Often problems
come from something which is omitted in a "from memory" description of the
code, rather than the raw code itself.

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
>

As remarked, you can't compare an int and a str; it is not meaningful.

Your code above _should_ have an int in the value of "guess". However, I
suspect your code actually may look like this:

 number=random.randint(1,20)
 guess=input()
 guess_value=int(guess)
 if guess<number:

and theat you should have "guess_value" in the "if" condition, not "guess".

i.e. I'm suggesting that you haven't put the int into "guess" but into some
other variable.

Cheers,
Cameron Simpson <cs at cskk.id.au> (formerly cs at zip.com.au)


More information about the Tutor mailing list