I am trying to solve the below problem:
Given an integer, n , and n space-separated integers as input, create a tuple, t , of those n integers. Then compute and print the result of hash(t).
I am using python 3. My code is
if __name__ == '__main__':
n = int(input())
integer_list = map(int, input().split())
t = tuple(integer_list)
print(hash(t))
The expected output is 3713081631934410656 but I am getting -3550055125485641917. I think my code is correct. Why am i getting a different output?
If I am using Pypy3, I am getting the correct output 3713081631934410656 but not with Python 3
integer_listandtto confirm your code actually does what you intendedinteger_listandtare right. The values are correct. When I give 2 and 1 2, theinteger_listis which is a map object, after converting to list the value is[1,2]thetwhich is a tuple, prints(1,2)I also tried printinghash((1,2))and it prints -3550055125485641917