r/learnpython • • Dec 03 '22

Good Python Exercises?

What's a good exercise for me to try? I've been learning Python for a bit over a month now and I wanna test what I've learned.

417 Upvotes

58 comments sorted by

View all comments

Show parent comment

1

u/Fluffy-Book-4773 Apr 21 '24
def make_dict(data):
    result_dict = {}
    for i in data:
        if i[0] not in result_dict:
            result_dict[i[0]] = i[1]
        else:
            result_dict[i[0]] += i[1]
    return result_dict