[Python] Why does hash((1, 2)) give different results on different systems in Python?

Discussão em 'Python' iniciado por Stack, Julho 25, 2025.

  1. Stack

    Stack Membro Participativo

    I'm solving a HackerRank problem where I'm supposed to:

    • Take an integer input n
    • Read n space-separated integers
    • Convert them into a tuple
    • Print the hash() of that tuple

    type hern = int(input())
    t = tuple(map(int, input().split()))
    print(hash(t))


    For input:

    2
    1 2


    Expected Output (as per HackerRank)
    3713081631934410656

    My Output (on local machine):
    -3550055125485641917

    Continue reading...

Compartilhe esta Página