• KeyError 'fight'

Question related to mission Army Battles

 

Dear All,

Please help to find where is a problem. In local PyScripter program works fine, but while checking it in CheckIO I have an error : KeyError 'fight' 25

Below program:

#

class Warrior:

  health = 50
  attack = 5
  is_alive = True

class Knight(Warrior):

  attack = 7

class Army(object):

def __init__(self):
    self.health_list = []
    self.attack_list = []


def add_units(self,soldier_type, amount):
    for _ in range(amount):
        self.health_list.append(soldier_type.health)
        self.attack_list.append(soldier_type.attack)
        self.health_sum = sum(self.health_list)
        self.attack_sum = sum(self.attack_list)

class Battle(object):

def fight(self,army1, army2):
    while army1.health_sum >0 and army2.health_sum>0:
        army1.health_sum -= army2.attack_sum
        army2.health_sum -= army1.attack_sum
        if army1.health_sum >0 and army2.health_sum<=0:
            return True
        elif army1.health_sum <= 0 and army2.health_sum >0:
            return False