Rite V. Looping the Spell
daemonpython
Rite V: Looping the Spell
Repetition is power. Cycles are truth. In the heart of every daemon, a loop turns endlessly.
In this rite, you will summon loops — structures that repeat actions until a condition changes. You’ve met for
loops before. Now we go deeper: into the while
loop, the eternal spiral, and how to command the flow of your spell.
I. The while
Loop
count = 0
while count < 3:
print("The glyph pulses.")
count += 1
What happens:
- It checks if
count
is less than 3. - If true: runs the block.
- Then adds 1 to
count
. - Repeats until
count
reaches 3.
Note: Without a condition that changes, a
while
loop becomes infinite. A trap spell. UseCtrl+C
to escape if needed.
II. The Eternal Spiral (Infinite Loop)
while True:
print("Summoning...")
Pair this with an escape keyword like break
:
while True:
response = input("Type 'exit' to leave the circle: ")
if response == "exit":
print("The circle breaks. The daemon rests.")
break
III. The continue
Rune
Skip the rest of a loop's body and go to the next cycle with continue
:
for sigil in ["Ash", "Void", "Null"]:
if sigil == "Void":
continue
print(f"Inscribing {sigil}")
This skips “Void” and continues with the next.
IV. Your Trial: The Gatekeeper
Summon a loop that:
- Asks for a password.
- Repeats until the user types the correct one.
- Then opens the gate.
secret = "daemon"
attempt = ""
while attempt != secret:
attempt = input("Whisper the password: ")
print("The gate opens.")
V. Reflection: Rhythm and Repetition
You now know:
-
while
loops — condition-based repetition -
break
— exit a loop at will -
continue
— skip a cycle -
input()
— user interaction - The dangers and uses of infinite loops
Your spells now possess rhythm, repetition, and control. You have mastered time inside the terminal.