Python's lambda allows you to declare a one-line nameless minifunction on the fly. The format is:
lambda parameter(s): expression using the parameter(s)
It returns the result of the expression. The expression has to be a one-liner (no newlines)! Here is a little example ...
# a list of player (name, score) tuples player_score = [('frank', 88), ('jerry', 68), ('albert', 99)] # use lambda to sort by score # (the item at index 1 in the tuple) player_score.sort(key=lambda tup: tup, reverse=True) print(player_score) # [('albert', 99), ('frank', 88), ('jerry', 68)]