Tracking Daily Attendance with Dictionaries in Python

Day 13/365: Tracking Daily Attendance with Dictionaries in Python 📊👨🏫 Today I worked on a simple but very practical problem in Python: updating a daily attendance record using a dictionary. 🔍 What this code does: I started with an attendance dictionary that stores how many days each student has attended so far. Then I created a today list that contains the names of students who attended class today. In this list, some names can appear more than once (for example, if the system logs multiple entries). Using a for loop, I go through each name in today and update the dictionary: attendance.get(name, 0) checks the current attendance count for that student. If the name is not already in the dictionary, it uses 0 as the default. Then I add 1 to this value and store it back in attendance[name]. In the end, print(attendance) shows the updated attendance record for all students. 💡 What I learned: How dictionaries are perfect for tracking counts or running totals for each item (like students, products, clicks, etc.). How dict.get(key, default) helps avoid errors when a key might not exist yet. How looping over a list and updating a dictionary can be used for real-world problems like: attendance systems, order frequency tracking in e‑commerce, counting events in logs or user actions. Day 13 done ✅ 352 more to go. If you have ideas like handling duplicate entries better, separating unique students per day, or generating attendance reports over a week/month, share them with me—I’d love to build on this next. #100DaysOfCode #365DaysOfCode #Python #LogicBuilding #Dictionaries #DataStructures #CodingJourney #LearnInPublic #AspiringDeveloper

  • graphical user interface, text, application

To view or add a comment, sign in

Explore content categories