Publish Date - February 5th, 2023|
Last Modified - March 7th, 2023
Given an integer, , and space-separated integers as input, create a tuple, , of those integers. Then compute and print the result of .
Note: hash() is one of the functions in the
__builtins__ module, so it need not be imported.
The first line contains an integer, , denoting the number of elements in the tuple.
The second line contains space-separated integers describing the elements in tuple .
Print the result of .
Sample Input 0
2 1 2
Sample Output 0
if __name__ == '__main__': n = int(input()) integer_list = map(int, input().split()) print(hash(tuple(integer_list)))
Simple solution, with you just printing out the tuple(integer_list).
Pretty much the only usage of code was the print function and tuple function, both are which handle single values. The mistake I made was thinking I needed to use LIST comprehension or something to loop through all of the values of the tuple (which was a wrong thought).
While this may not be a machine learning or NLP problem, understanding the basics are important!
Thanks for reading!