Mar-03-2020, 02:58 AM
(Mar-03-2020, 02:08 AM)snippsat Wrote: Connect the two list to a dictionary,then can usemax()
withkey
parameter.
>>> rainfall = [10, 20, 30] >>> months = ['January', 'February', 'March'] >>> rainfall_record = dict(zip(months, rainfall)) >>> rainfall_record {'January': 10, 'February': 20, 'March': 30} >>> >>> month, amount = max(rainfall_record.items(), key=lambda x:x[1]) >>> month 'March' >>> amount 30
THANK YOU! took me a little bit to figure out how to use all of that and what it did but it worked! thank you!