For this Question: Given a list of tuples, sort by the second element of the tuple in descending order1st line: number of tuples to be added to the list ie n
next n line: 2 space values as tuplesprint the sorted list of tuplesInput:
6
4 10 
2 2 
8 6 
6 4 
7 2 
6 5 
Output:
[(4, 10), (8, 6), (6, 5), (6, 4), (2, 2), (7, 2)]

Explanation: Here the list is sorted by the second element of the tuple like the second elements of the list [(4, 10), (8, 6), (6, 5), (6, 4), (2, 2), (7, 2)] is 10,6,5,4,2,2 which are in descending order, I have written this Solution Code: n=int(input())
a=[]
for i in range(n):
  tmp=input().strip().split()
  a.append((int(tmp[0]),int(tmp[1])))
a=sorted(a,key=lambda x:x[1],reverse=True)
print(a), In this Programming Language: Python, Now tell me if this Code is compilable or not?