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
|
1821 Discussions
|
Please Login in order to post a comment
I had to switch the language to python 2 and use raw_input() instead of input() to get it to work. It seems that the hash function works differently in python 3 than it did in python 2, which is likely the version of python this challenge was written for. HackerRank really needs to update this challenge for python 3!
This is my python 2 code I used:
compute and print the hash
print hash(elements)
Here is - Javascript project for students
For some reason, Python 3 throws wrong answer. It generates correct answer with Python 2.
if name == 'main':
n = int(input())
t = tuple(map(int, input().split()))
print(hash(t))
our Output (stdout)
-3550055125485641917 `
I Didn't understand how to use the hash() please explain
if your using the python 2 then use this code
if name == 'main': n = int(raw_input()) integer_list = map(int, raw_input().split()) t = tuple(integer_list) print hash(t)
in python 2 to take the input we need to use the raw_input()