Hello everyone,
I had a different answer than the given solution and I was wondering if my thought process is valid.
Here’s My code:
python_top_articles = python_top['data']['children']
most_upvoted = {}
for post in python_top_articles:
most_upvoted[post['data']['id']] = post['data']['ups']
most_upvoted = max(most_upvoted, key=most_upvoted.get)
Here’s the solution:
python_top_articles = python_top["data"]["children"]
most_upvoted = ""
most_upvotes = 0
for article in python_top_articles:
ar = article["data"]
if ar["ups"] >= most_upvotes:
most_upvoted = ar["id"]
most_upvotes = ar["ups"]
Thank you.