# while sets the pace — for does the work
# while + for — outer controls duration, inner processes sequences

import random

# ─────────────────────────────────────────────
# Basic while + for
# ─────────────────────────────────────────────

attempts = 0

while attempts < 3:
    word = random.choice("bull horn red".split())
    print(f"\nWord: {word}")
    for letter in word:
        print(f"  {letter}")
    attempts += 1

# while runs 3 times
# each time — random picks a word — for loops through every letter

# ─────────────────────────────────────────────
# Real example — input and process
# ─────────────────────────────────────────────

while True:
    word = input("Enter a word (or 'quit'): ")
    if word == "quit":
        break
    count = 0
    for letter in word:
        if letter.lower() in "aeiou":
            count += 1
    print(f"Vowels in '{word}': {count}")

# while True keeps asking
# for counts vowels in each word
# user decides when to stop

# ─────────────────────────────────────────────
# break in while + for
# ─────────────────────────────────────────────

while True:
    word = input("Enter a word (or 'quit'): ")
    if word == "quit":
        break               # stops the while loop
    for letter in word:
        if letter == "x":
            print("Found x — skipping rest of word.")
            break           # stops the for loop only
        print(letter)

# outer break stops while
# inner break stops for only — while keeps going

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

# while condition:         — controls duration
#     for item in seq:     — processes sequence
#         block
#
# break inside for — stops for only, while keeps going
# update while condition inside loop — or runs forever
# for runs completely on every while iteration
