Advertisement
elena1234

max function with lambda in Python

May 20th, 2022
862
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data Copied
Advertisement