0

Understanding dictionary and lambda

I need help understanding this piece of code, it's returning the most and less repeated element in a list, if there are elements that are repeated the same amount of times it returns the key which is greater the #! Is code I've added I've tried it and it works apparently it's finding the less repeated element. I explain which parts I'm unable to understand inside the code https://code.sololearn.com/cA120A39a0A4/?ref=app

11th Jun 2021, 2:53 AM
Jace🎭
Jace🎭 - avatar
3 odpowiedzi
+ 1
You can sort by default criteria or by own criteria. In first case you don't need lambda. In second case u need a lambda to describe how to sort.
11th Jun 2021, 7:19 AM
Oma Falk
Oma Falk - avatar
+ 1
Play around with the code and see what happens if u change the lambda.
11th Jun 2021, 7:32 AM
Oma Falk
Oma Falk - avatar
0
I think I finally got it the lambda is using - sings to invert the order of the list of tuples, so that we can later return the first index, but it still seems like I'm just able to see a part of what the code is doing, I'll just keep looking into it :D
11th Jun 2021, 4:28 AM
Jace🎭
Jace🎭 - avatar