Day 27 Of Documenting My Learning Journey

Published: (December 19, 2025 at 02:42 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

What I learnt Today

  • How to define dictionaries using the dict constructor and curly braces {}.
  • How to access elements in a dictionary using the .get() method and bracket notation [].
  • How to add and update elements in a dictionary.
  • How to loop through keys, values, and both keys and values using a for loop.

On what I learnt Today

Assumption: we have a dictionary named person.

Defining

person = {
    "name": "James",
    "age": 23,
    "Occupation": "Engineer"
}

Accessing Elements

print(person["name"])          # or
print(person.get("name"))

Adding Elements

person["status"] = "Graduated"

Updating Elements

person["age"] = 20

Removing an Element

person.pop("status")

Looping through Keys

for key in person:
    print(key)

Looping through Values

for value in person.values():
    print(value)

Looping through Keys and Values

for key, value in person.items():
    print(f"{key} -> {value}")

Resources I used

  • Python refresher series by Bonaventure Ogeto on YouTube.

What’s Next

  • Understanding sets and tuples.
Back to Blog

Related posts

Read more »

Day 12: Python Programming

PART-1: LIST – Advanced Concepts List Comprehension - With condition Nested List Comprehension List Slicing Important List Methods Example: python Example...