Computer Science, asked by scgchjvm2m, 8 hours ago

Teachers of Indian Academy Public School collect the names of those students who are going to participate in the Mathematics exhibition, that is to be held in a week’s time. They have collected all the names and now, they want to store all the names into a system, in the descending order of the length of the names. This means, the longest name should get stored first, followed by the name that is shorter than the previous, and so on. Can you help the teachers to perform this task easily by creating a program in Python?

Answers

Answered by pragyakirti12345
1

Answer: Python program

Explanation:

n = int((input())

list1 = []

for i in range(n):

       val = input()

       list1.append(val)

print(sorted(list1, key=lambda x: (len(x), x), reverse=True))

#SPJ3

Similar questions