# More conditions, smarter loop
# while + and, or, not — multiple conditions, one loop

# ─────────────────────────────────────────────
# while with and — both must be True
# ─────────────────────────────────────────────

attempts = 0
password = "RedHorn"
answer = ""

while answer != password and attempts < 3:
    answer = input("Enter password: ")
    attempts += 1

if answer == password:
    print("Access granted.")
else:
    print("Too many attempts. Locked out.")

# loop runs while password is wrong AND attempts remain
# either condition failing — loop stops

# ─────────────────────────────────────────────
# while with or — at least one must be True
# ─────────────────────────────────────────────

health = 10
ammo = 3

while health > 0 or ammo > 0:
    print(f"Health: {health} | Ammo: {ammo}")
    health -= 3
    ammo -= 1

# both must fail for the loop to stop

# ─────────────────────────────────────────────
# while with not — flag variable
# ─────────────────────────────────────────────

done = False

while not done:
    answer = input("Type 'quit' to stop: ")
    if answer == "quit":
        done = True

print("Stopped.")

# not done is True while done is False
# when done becomes True — not done is False — loop stops

# ─────────────────────────────────────────────
# Combining all three
# ─────────────────────────────────────────────

score = 100
lives = 3
game_over = False

while score > 0 and lives > 0 and not game_over:
    print(f"Score: {score} | Lives: {lives}")
    score -= 20
    lives -= 1

# any one condition failing — loop stops

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

# and  — both must be True to keep looping
# or   — at least one must be True to keep looping
# not  — inverts the condition
# use parentheses when combining multiple conditions
