# Keeping score — the loop counter
# track what's happening inside the loop — iteration by iteration

# ─────────────────────────────────────────────
# Counting iterations
# ─────────────────────────────────────────────

word = "Bull"
count = 0

for letter in word:
    count += 1

print(f"Loop ran {count} times.")    # Loop ran 4 times.

# ─────────────────────────────────────────────
# Adding up values
# ─────────────────────────────────────────────

word = "RedHorn"
total = 0

for letter in word:
    total += 1

print(f"Total characters: {total}")    # Total characters: 7

# ─────────────────────────────────────────────
# Subtracting with -=
# ─────────────────────────────────────────────

fuel = 100

for stop in range(5):
    fuel -= 10
    print(f"After stop {stop + 1}: {fuel} units remaining")

# After stop 1: 90 units remaining
# After stop 2: 80 units remaining
# After stop 3: 70 units remaining
# After stop 4: 60 units remaining
# After stop 5: 50 units remaining

# ─────────────────────────────────────────────
# Multiplying with *=
# ─────────────────────────────────────────────

value = 1

for i in range(1, 6):
    value *= i
    print(f"{i}! = {value}")

# 1! = 1
# 2! = 2
# 3! = 6
# 4! = 24
# 5! = 120

# ─────────────────────────────────────────────
# The pattern
# ─────────────────────────────────────────────

# 1. define the variable BEFORE the loop
counter = 0

# 2. update it INSIDE the loop
for letter in "Bull":
    counter += 1    # or -=, *=, whatever you need

# 3. use it AFTER the loop
print(counter)    # 4

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

# define before  — not inside, or it resets every iteration
# += adds        — accumulates
# -= subtracts   — depletes
# *= multiplies  — scales
# variable holds its value after the loop ends
