You are viewing a single comment's thread. Return to all comments →
Turning the list into a set removes all the duplicate elements. Sorting the result puts the lowest element at index 0, the second lowest at index 1.
That's why he converted to a set and back.
The second conversion isn't necessary, in fact, as the sorted function returns a sequence. But the idea is sound and this code will pass the tests.
You could copy and paste the code, try it out with an input where there are two lowest scores - you'll find it works.
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 →
Turning the list into a set removes all the duplicate elements. Sorting the result puts the lowest element at index 0, the second lowest at index 1.
That's why he converted to a set and back.
The second conversion isn't necessary, in fact, as the sorted function returns a sequence. But the idea is sound and this code will pass the tests.
You could copy and paste the code, try it out with an input where there are two lowest scores - you'll find it works.