May-31-2022, 12:22 PM
I have a list of students and I have to print the names of students who have scored second lowest.
students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
The lowest grade of belongs to Tina. The second lowest grade of belongs to both Harry and Berry, so we order their names alphabetically and print each name on a new line.
I am extremely new to python so I have coded as below -
students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
The lowest grade of belongs to Tina. The second lowest grade of belongs to both Harry and Berry, so we order their names alphabetically and print each name on a new line.
I am extremely new to python so I have coded as below -
studList = [] for i in range(int(input())): name = input() score = float(input()) studList.append([name,score]) studList = sorted(studList, key = lambda x: x[1], reverse = True) print(studList)I have done till the point that I now have a sorted list but now I am not sure I do I extract the second lowest scorer's names.