[Python] TypeError: '<' not supported between instances of 'NoneType' and 'int'. Anyone knows...

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    Here's the code.

    digs = (-10, 0, 7, -2, 3, 6, -8)

    def sort(x):
    if x < 0:
    return False

    print(sorted(digs, key=sort))


    When launched the following error appears. Can anyone explain why?

    I figured it out that I can do this:

    def sort(x):
    return x >= 0


    and it's gonna work fine. But I still don't get why that error shows up when comparing x and 0.

    Continue reading...

Compartilhe esta Página