We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Basic Data Types
- Tuples
- Discussions
Tuples
Tuples
Sort by
recency
|
1767 Discussions
|
Please Login in order to post a comment
I can't understand what is wrong with my code? if name == 'main': n = int(input()) a=input().split() tup=tuple(a) print(hash(tup))
Yes HR need to fix this. Output is very specific to python version.
Proof: $python3 Python 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.
$ python2 Python 2.7.18 (default, Dec 9 2024, 18:47:23) [GCC 11.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information.
dont waste your time, knocking head for this problem. The solution is designed based on python 2 , and hash function is giving different output in python 2 and 3, so solve it in python 2 only.
if name == 'main': n = int(raw_input()) integer_list = map(int, raw_input().split())
print(result)
You must solve this in Python 2 to get the correct answer
There are several key differences between the hash() function in Python 2 and Python 3:
Python 2: Used a non-cryptographic hash algorithm called FNV (Fowler-Noll-Vo) which was fast but vulnerable to collisions.
Python 3: Uses a more secure algorithm called SipHash which is designed to be resistant to hash collision attacks.