[Python] "is not" with list having value above 256 in python [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 25, 2024.

  1. Stack

    Stack Membro Participativo

    Why is the output of this Python code so unexpected?

    for ind, elem in enumerate(range(260)):
    if ind is not elem:
    print(ind , elem)


    I was expecting no output but the output is-

    257 257 258 258 259 259


    Whereas this code gives no output, as expected-

    for ind, elem in enumerate(range(260)):
    if ind != elem:
    print(ind , elem)

    Continue reading...

Compartilhe esta Página