Preplp
Daily Python
Day 8Python~40 min

Dictionaries

Key-value data for contacts and records

Track progress0/15 days
x

What you'll learn

dictkeysvaluesitemsin
  • Create and update dictionaries
  • Loop with .items()
  • Build a contact book with CRUD menu

Lesson & examples

Read the code, then the explanation — try changing values before the project.

Contact dict
contact = {"name": "John", "phone": "123-456-7890"}
contact["email"] = "john@example.com"
for key, value in contact.items():
    print(f"{key}: {value}")

Today's exercise: Contact Book

Store contacts by name with phone and email; search, edit, and delete.

Steps

  1. 1

    contacts = {}

    Use name as key, nested dict for phone and email.

  2. 2

    Menu functions

    add_contact, view_contacts, search, edit, delete.

Full project source — copy into a folder or use the zip above

starter.py
contacts = {}

def show_menu():
    print("\n--- Contact Book ---")
    print("1. Add  2. View  3. Search  4. Edit  5. Delete  6. Exit")

def add_contact():
    name = input("Name: ")
    phone = input("Phone: ")
    email = input("Email: ")
    contacts[name] = {"phone": phone, "email": email}
    print(f"{name} added.")

while True:
    show_menu()
    choice = input("Choice: ")
    if choice == "1":
        add_contact()
    elif choice == "2":
        for name, d in contacts.items():
            print(f"{name}: {d['phone']}, {d['email']}")
    elif choice == "6":
        break
    else:
        print("Implement or extend this branch!")

One rehearsal platform

Certification mocks, daily lessons, project labs, and in-browser drills

Structured for exam day and portfolio proof — timed tests, guided builds, and quick reps on one platform.