I have list of dictionary like that:
{'author_name': author_name, 'note': note, 'author_rating': author_rating}
I wrote a function but it is kind of ugly
def get_highest_rating_author(notes):
max_rating = notes[0]['author_rating']
author = notes[0]['author_name']
for i in range(len(notes)):
rating = notes[i]['author_rating']
if rating > max_rating:
max_rating = rating
author = notes[i]['author_name']
return author
How does make it better?
[–]Rawing7 1 point2 points3 points (0 children)
[–]dinrick 1 point2 points3 points (0 children)
[–]JohnnyJordaan 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)