Advertisement
elena1234

max function with lambda in Python

May 20th, 2022
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. valid_albums = [row for row in albums if return_valid_year(row["Year"])]
  2. most_recent_album = max(valid_albums, key = lambda x: x["Year"])
  3. print("Most recent album is \"{0}\" by \"{1}\".".format(most_recent_album["Album"], most_recent_album["Artist"]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement