We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
using set() removes duplicates; using list() turns it back into a list
but sorted() also returns a list even if it's passed a set, so the use of list is not necessary
the list comprehension is taking marksheet, which has 2-element lists in it, and just getting one of the elements; it's turning [[name1,mark1],[name2,mark2],...] into [mark1,mark2,...].
also, the casting and sorting can be replaced by calling max:
Nested Lists
You are viewing a single comment's thread. Return to all comments →
using
set()
removes duplicates; usinglist()
turns it back into a listbut
sorted()
also returns a list even if it's passed a set, so the use oflist
is not necessarythe list comprehension is taking
marksheet
, which has 2-element lists in it, and just getting one of the elements; it's turning[[name1,mark1],[name2,mark2],...]
into[mark1,mark2,...]
.also, the casting and sorting can be replaced by calling
max
: