# Tell Python where to start and where to stop
# range() — generates a sequence of numbers on demand

# ─────────────────────────────────────────────
# range(stop)
# ─────────────────────────────────────────────

for i in range(5):
    print(i)

# 0
# 1
# 2
# 3
# 4

# starts at 0, stops before 5 — stop is never included

# ─────────────────────────────────────────────
# range(start, stop)
# ─────────────────────────────────────────────

for i in range(1, 6):
    print(i)

# 1
# 2
# 3
# 4
# 5

# starts at 1, stops before 6

# ─────────────────────────────────────────────
# range(start, stop, step)
# ─────────────────────────────────────────────

for i in range(0, 10, 2):
    print(i)

# 0
# 2
# 4
# 6
# 8

# jumps by 2 each time

# ─────────────────────────────────────────────
# Counting backwards
# ─────────────────────────────────────────────

for i in range(5, 0, -1):
    print(i)

# 5
# 4
# 3
# 2
# 1

# negative step — Python counts down

# ─────────────────────────────────────────────
# range() with len()
# ─────────────────────────────────────────────

word = "Bull"

for i in range(len(word)):
    print(f"Index {i}: {word[i]}")

# Index 0: B
# Index 1: u
# Index 2: l
# Index 3: l

# range(len(word)) gives exactly as many numbers as characters

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

# range(stop)             — 0 to stop-1
# range(start, stop)      — start to stop-1
# range(start, stop, step) — jump by step each time
#
# stop is never included — always
# default step is 1
# negative step counts backwards
# range() generates numbers one at a time — not stored in memory
