-
-
Save stephengruppetta/95d9d63556047eca77a0e3b4c5f187f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
numbers = [random.randint(1, 50) for _ in range(20)] | |
print(numbers) | |
# "Standard" use of 'max()' | |
print( | |
max(numbers) | |
) | |
# 'max()' with a different rule. | |
# Can you figure out the rule? | |
print( | |
max( | |
numbers, | |
key=lambda x: sum(int(y) for y in str(x)), | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment