# Read the list. Don't change it.
# inspection methods — in, len, index, count, copy, min, max, sum

squad = ["Raven", "Wolf", "Ghost", "Viper", "Bull"]

# ─────────────────────────────────────────────
# in / not in — check if a value exists
# ─────────────────────────────────────────────

print("Wolf" in squad)          # True
print("Fox" in squad)           # False
print("Fox" not in squad)       # True

# useful with if
if "Ghost" in squad:
    print("Ghost is on the list.")

# ─────────────────────────────────────────────
# len() — number of elements
# ─────────────────────────────────────────────

print(len(squad))               # 5

empty = []
print(len(empty))               # 0

# ─────────────────────────────────────────────
# index() — position of first match
# ─────────────────────────────────────────────

print(squad.index("Ghost"))     # 2
print(squad.index("Raven"))     # 0

# if value appears more than once — returns first index only
duplicates = ["Wolf", "Raven", "Wolf", "Bull"]
print(duplicates.index("Wolf")) # 0

# safe pattern — check before calling index()
if "Fox" in squad:
    print(squad.index("Fox"))
else:
    print("Not in the list.")   # Not in the list.

# squad.index("Fox")            # ValueError — not in list

# ─────────────────────────────────────────────
# count() — how many times a value appears
# ─────────────────────────────────────────────

scores = [85, 74, 85, 91, 85, 63]
print(scores.count(85))         # 3
print(scores.count(74))         # 1
print(scores.count(99))         # 0  — no error if not found

status = ["active", "inactive", "active", "active"]
print(status.count("active"))   # 3

# ─────────────────────────────────────────────
# copy() — independent copy of the list
# ─────────────────────────────────────────────

squad = ["Raven", "Wolf", "Ghost"]
backup = squad.copy()

backup.append("Viper")

print(squad)    # ['Raven', 'Wolf', 'Ghost']        — unchanged
print(backup)   # ['Raven', 'Wolf', 'Ghost', 'Viper']

# without copy() — both variables point to the same list
a = ["Raven", "Wolf"]
b = a                   # NOT a copy — same list
b.append("Ghost")

print(a)        # ['Raven', 'Wolf', 'Ghost']        — changed too
print(b)        # ['Raven', 'Wolf', 'Ghost']

# ─────────────────────────────────────────────
# min(), max(), sum() — for number lists
# ─────────────────────────────────────────────

scores = [85, 74, 91, 63, 98]

print(min(scores))      # 63
print(max(scores))      # 98
print(sum(scores))      # 411

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

# x in list          — True if x exists in list
# x not in list      — True if x does not exist
# len(list)          — number of elements
# list.index(x)      — index of first x (ValueError if missing)
# list.count(x)      — number of times x appears (0 if missing)
# list.copy()        — independent copy of the list
# min(list)          — smallest value (numbers only)
# max(list)          — largest value (numbers only)
# sum(list)          — total of all values (numbers only)
#
# none of these modify the original list
