CHALLENGE 3: A Health Countdown With while and if/elif/else ==================================================================== TASK ---- Write a script that starts a player at 100 health and, using a while loop, subtracts 15 health per iteration. Inside the loop, use if/elif/else to print "Critical!", "Hurt", or "Healthy" depending on the current health, and stop the loop once health reaches 0 or below. SOLUTION CODE ------------- extends Node2D func _ready() -> void: var health: int = 100 while health > 0: if health <= 20: print(str(health) + " HP - Critical!") elif health <= 60: print(str(health) + " HP - Hurt") else: print(str(health) + " HP - Healthy") health -= 15 OUTPUT ------ 100 HP - Healthy 85 HP - Healthy 70 HP - Healthy 55 HP - Hurt 40 HP - Hurt 25 HP - Hurt 10 HP - Critical! WHY THIS WORKS AS AN ANSWER ---------------------------- while health > 0 is the loop's own stopping condition - the moment health drops to 0 or below, the while condition becomes false and the loop ends on its own, which is exactly what "stop the loop once health reaches 0 or below" is asking for. No separate break statement is needed because the condition itself already expresses that rule. The if/elif/else chain is checked fresh on every iteration, using whatever health currently is at that point - health <= 20 is checked first (the most specific, narrowest case), falling through to health <= 60 only if the first check fails, and finally to else for anything higher. Ordering the checks from most specific to least specific is what makes a chain like this behave correctly - checking health <= 60 first would incorrectly also catch every "Critical!" case, since 20 is also less than or equal to 60. health -= 15 at the end of the loop body is what actually makes progress happen - without it, health would never change and the loop would run forever.