Skip to content

Commit

Permalink
use the more pythonic key=func syntax for max function
Browse files Browse the repository at this point in the history
  • Loading branch information
pybites committed Jan 15, 2017
1 parent 36c4227 commit 073d202
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 02/game-help.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _get_permutations_draw(draw):
# From challenge 01:
def max_word_value(words):
"""Calc the max value of a collection of words"""
return max(words, key=lambda w: calc_word_value(w))
return max(words, key=calc_word_value)


def main():
Expand Down
3 changes: 2 additions & 1 deletion 02/game-nohelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ def calc_word_value(word):
# re-use from challenge 01
def max_word_value(words):
"""Calc the max value of a collection of words"""
return max(words, key=lambda w: calc_word_value(w))
return max(words, key=calc_word_value)


def main():
pass


if __name__ == "__main__":
main()

0 comments on commit 073d202

Please sign in to comment.