While loop : While « Language Basics « Python
- Python
- Language Basics
- While
While loop

health = 10
trolls = 0
damage = 3
while health >0: #!= 0:
trolls += 1
health = health - damage
print " " \
"but takes", damage, "damage points.\n"
print " ", trolls, "trolls."
Related examples in the same category