An input of n integers is taken at the run time. n integers are taken as input in a single line, separated by a space. We have to create a tuple of this n integers and perform hash(tuple) function on it and give the output.
Asked
Active
Viewed 36 times
0
-
Use `input()` to input the line. That will give you a string. Use the string method `split()` to split the line on spaces. That you will give you a list. Call `tuple(mylist)` to turn the list into a tuple. – BoarGules Mar 28 '19 at 16:24
-
Possible duplicate of [Add Variables to Tuple](https://stackoverflow.com/questions/1380860/add-variables-to-tuple) – Masoud Rahimi Mar 28 '19 at 16:59
1 Answers
4
Here it is:
def your_homework():
return hash(tuple([int(i) for i in input("give me n integers").split()]))

adrtam
- 6,991
- 2
- 12
- 27