key argument can also be used with some of the other functions we've learned in this course, such as
max(). Here's an example:
products = [
'SuperPower3000', 'maxVoltage 2',
'ELECTROKING', 'aMpLiFiEr 52S',
'AlternatingCurrent', 'el3ctric 2.0'
print(max(products)) # maxVoltage 2
print(max(products, key=len)) # AlternatingCurrent
max(products) returns the last string (lexicographically speaking), which is
'maxVoltage 2' in this case. However, we changed the default behavior on the last line, where we specified the
len() function as the
key. Now, the maximum element is
'AlternatingCurrent', which is the longest string in the list.