# The loop that does the work for you
# for loops — write it once, run it as many times as needed

# ─────────────────────────────────────────────
# Basic for loop — string
# ─────────────────────────────────────────────

word = "Bull"

for letter in word:
    print(letter)

# B
# u
# l
# l

# ─────────────────────────────────────────────
# The loop variable is yours
# ─────────────────────────────────────────────

name = "RedHorn"

for character in name:
    print(character)

# character, letter, c — all valid
# pick something that makes the code readable

# ─────────────────────────────────────────────
# Doing something with each item
# ─────────────────────────────────────────────

word = "Bull"

for letter in word:
    print(f"Current letter: {letter}")

# Current letter: B
# Current letter: u
# Current letter: l
# Current letter: l

# ─────────────────────────────────────────────
# Counting with +=
# ─────────────────────────────────────────────

word = "Bull"
count = 0

for letter in word:
    count += 1

print(f"Letters counted: {count}")    # 4

# the loop runs once per character
# count goes up by 1 each time
# after the loop — the total is ready

# ─────────────────────────────────────────────
# Checking your work with len()
# ─────────────────────────────────────────────

word = "Bull"
count = 0

for letter in word:
    count += 1

print(f"Counted manually: {count}")        # 4
print(f"Confirmed by len(): {len(word)}")  # 4

# same result — your loop did what len() does

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

# for item in sequence:   — colon is mandatory
#     block               — 4 spaces indentation
#
# loop variable holds the current item on each iteration
# variables outside the loop can be updated inside with +=
# len() returns the number of characters in a string
# if the sequence is empty — block never runs, no error
