# From empty to full.
# dict creation — every way Python lets you build one

# ─────────────────────────────────────────────
# Dict literal — keys and values known upfront
# ─────────────────────────────────────────────

soldier = {"name": "Raven", "score": 85, "active": True}
print(soldier)
# {'name': 'Raven', 'score': 85, 'active': True}

# spread across lines for readability
soldier = {
    "name":   "Raven",
    "score":  85,
    "active": True
}

# any value type is valid
profile = {
    "callsign": "Ghost",
    "score":    91,
    "gear":     ["rifle", "vest", "radio"],
    "active":   True
}

# ─────────────────────────────────────────────
# Empty dict — filled later
# ─────────────────────────────────────────────

roster = {}             # most common
backup = dict()         # same result

print(roster)           # {}
print(backup)           # {}

# ─────────────────────────────────────────────
# dict() with keyword arguments
# ─────────────────────────────────────────────

soldier = dict(name="Raven", score=85, active=True)
print(soldier)
# {'name': 'Raven', 'score': 85, 'active': True}

# only works for simple keys — no spaces, hyphens, or leading numbers
# dict(first-name="Raven")   # SyntaxError

# ─────────────────────────────────────────────
# dict(zip()) — build from two lists
# ─────────────────────────────────────────────

names  = ["Raven", "Wolf", "Ghost"]
scores = [85, 74, 91]

result = dict(zip(names, scores))
print(result)
# {'Raven': 85, 'Wolf': 74, 'Ghost': 91}

# zip stops at the shorter list
names_long   = ["Raven", "Wolf", "Ghost", "Viper"]
scores_short = [85, 74, 91]

result = dict(zip(names_long, scores_short))
print(result)
# {'Raven': 85, 'Wolf': 74, 'Ghost': 91}   — Viper dropped

# ─────────────────────────────────────────────
# Adding keys one at a time
# ─────────────────────────────────────────────

roster = {}
roster["Raven"] = 85    # creates new key
roster["Wolf"]  = 74
roster["Ghost"] = 91
print(roster)
# {'Raven': 85, 'Wolf': 74, 'Ghost': 91}

roster["Raven"] = 99    # updates existing key — no error
print(roster)
# {'Raven': 99, 'Wolf': 74, 'Ghost': 91}

# ─────────────────────────────────────────────
# Quick reference
# ─────────────────────────────────────────────

# {"key": value}             — dict literal
# {}                         — empty dict
# dict()                     — empty dict
# dict(key=value)            — keyword arguments (simple keys only)
# dict(zip(keys, values))    — from two lists
# d["key"] = value           — add or update a key
#
# {} is an empty dict — not an empty set (use set() for that)
# duplicate keys — last value wins, no error
# dict(zip()) stops at the shorter list
