I'm making a simple turn-based fighting game in Python 3. My while loop won't finish when the health of the computer is 0 or below.
I couldn't find any posts answering my problem. I have tried some different kinds of conditions but it either stops before the loop or doesn't stop.
from random import randint
def punch():
return randint(18, 25)
c_health = 100
p_health = 100
while(c_health and p_health > 0):
move = input("Pick a move (punch, kick or heal): ").lower()
if move == "punch":
damage = punch()
c_health = c_health - damage
print(f"You have dealt {damage} dmg.")
print(f"The computer has {c_health} health.")
elif move == "kick":
print(kick())
elif move == "heal":
print(heal())
I expect the while loop to finish when the c_health reaches 0 or below.