You are viewing a single comment's thread. Return to all comments →
actually here they are trying to do everything in 1 line we can split tbis code as well ,
set(scorelist) will create a set of score list (we can use dict.from keys as well because we need to rule out the duplicate entries)
list(set(scorelist)) will create a list of set, you can create a list of dictionary as well
sorted will sort your list of set(scorelist)
[1] will point to the second element in the sorted list beause we want to print the 2nd smallest element in the list
and now we store it in the b variable
a and c are the names and scores we have already stored in the marksheet
so we are comparing that if c == b that is is core in the marksheet is equal to the secondlowest score that we just found out we will print a
now a is the name that is what the question is asking huh!
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →
actually here they are trying to do everything in 1 line we can split tbis code as well ,
set(scorelist) will create a set of score list (we can use dict.from keys as well because we need to rule out the duplicate entries)
list(set(scorelist)) will create a list of set, you can create a list of dictionary as well
sorted will sort your list of set(scorelist)
[1] will point to the second element in the sorted list beause we want to print the 2nd smallest element in the list
and now we store it in the b variable
a and c are the names and scores we have already stored in the marksheet
so we are comparing that if c == b that is is core in the marksheet is equal to the secondlowest score that we just found out we will print a
now a is the name that is what the question is asking huh!