-2

I got this code, I understood everything but I can't understand this "marks for name, marks in marksheet", What is meant by marks,for,name and marksheet, explain it briefly

marksheet = []
for i in range(0,int(input())):
    marksheet.append([raw_input(), float(input())])

second_highest = sorted(list(set([marks for name, marks 
in marksheet])))[1]
print('\n'.join([a for a,b in sorted(marksheet) if b == 
second_highest]))
Pa1 Kumar
  • 15
  • 2
  • 1
    Do you understand the next list comprehension `[a for a, b in sorted(marksheet) <...>]` which has roughly the same structure? – user202729 Dec 08 '18 at 04:12

2 Answers2

0

Each element of your mark sheet is a list with two elements: a name and a mark. So by using for name, mark in marksheet, your code knows to reference the elements inside of your list.

Jack Moody
  • 1,590
  • 3
  • 21
  • 38
-2
second_highest = sorted(list(set([d for c, d in marksheet])))[1] #c: 'Berry' d: 37.21

It's a same way to run successfully.

Toto
  • 1
  • 3