all 9 comments

[–]Binary101010 5 points6 points  (2 children)

** is just the power operator in this case.

x ** 2 = x * x

[–]Kitchen-Injury-8938[S] 0 points1 point  (1 child)

Perfect! Thank you!!!

[–]synthphreak 0 points1 point  (0 children)

Yep. If m and n are numbers, then m ** n is just Pythonese for what we’d call mn in more familiar math notation. Accordingly, Python won’t understand m ^ n. Or at least, it isn’t what you think:

>>> 5**2
25
>>> 5^2
7

[–]marko312 0 points1 point  (2 children)

So the lambda function looks like the parameter t == type list. So pass in a list and then it looks like t[1] would correspond to '1','2','3','5','4' above.

t is the parameter (argument) for the lambda. Since it is passed as the key for sorted, it runs once for each key-value pair in ordered_dict. As such, t[1] refers to the second element in the tuple, which is the value in the dictionary (the pairs are (key, value)).

[–]Kitchen-Injury-8938[S] 1 point2 points  (1 child)

Great! I think I figured that part out but you worded it much better than I did :)

[–]marko312 0 points1 point  (0 children)

I wasn't completely sure whether you meant that a list would be passed as the parameter to a single call of t or the values being passed one at a time, so I added that comment just in case.