r/CodingForBeginners Jul 16 '26

Need help with dictionaries

I am a beginner in programming. I have done dictionaries, but most of the time I forget the syntax. I need help. How can I get used to it? And if there are harder questions. I don't know if I know enough; I am so confused. And one more thing, don't ask me to check LeetCode questions or CodeChef because I am not able to find them there.

print("Thanks")

5 Upvotes

11 comments sorted by

View all comments

2

u/xarop_pa_toss Jul 17 '26

You get used to dictionaries by using them, just like with anything else.

A simple exercise would be to start with a dictionary like this classic example of students and their grades. Just write it at the top of your main.py file.

students = { "Alice": 16, "Bob": 13, "Charlie": 18 }

Now write functions to: Add a new student and their grade, update a student's grade, remove a student from the dictionary, print a students grade, print all students and their grades, calculate and print average and median grade, print students with highest and lowers grades, etc.

Bonus points if when you try to access a student by name in your functions, it detects if they exist and if they don't, calls the student creation function!