• + 0 comments

    Your approach would work for integers entered on separate lines like this: 2 1 2

    But the input is expecting the size to be the first line and space separated values on the second line. You can use the split() method to create a list out of space separated input values and then convert the list to integer values using the built-in map() function to create a map object. Then you convert that map object to the desired structure so that would be a tuple with the tuple() method in this case.

    Here's the modified code:

    n = int(input())

    temp_l = map(int, input().split())

    temp_tup = tuple(temp_l)

    print(hash(temp_tup))

    Here is your code modified: