# Follow me on youtube channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q
# Attack when your soldiers' total health is greater
# than the ogres' total health
# This function return the sum of all the units' health.
def sumHealth(enemies):
totalHealth = 0
# Complete this function:
#enemies=hero.findEnemies()
enemyIndex=0
while enemyIndex<len(enemies):
totalHealth+=enemies[enemyIndex].health
enemyIndex+=1
return totalHealth
while True:
friends = hero.findFriends()
enemies = hero.findEnemies()
# Get the total health of your soldiers and the ogres.
if sumHealth(friends) <= sumHealth(enemies):
hero.say("Wait")
# Say "Attack" when your side has more total health.
else:
hero.say("ATTACK!!!")