Is this a valid answer?

Hello everyone,
I had a different answer than the given solution and I was wondering if my thought process is valid.

Here’s the link

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.


Yes, your approach is perfectly fine for the task.

Your answer makes a lot more sense to me either, @RayOjel! :clap: :clap: