Mad maxer : redemption . error about a function that it's not even in my code

here’s my code , it has worked perfectly untill the error pop out and just my code just stop running

while True:
    weakestFriend = None
    leastHealth = 9999
    friendIndex = 0
    friends = hero.findFriends()
    while friendIndex < len(friends) :
        friend = friends[friendIndex]
        friendIndex +=1
        health = friend.health
        if health < leastHealth:
            leastHealth = health
            weakestFriend = friend
    if weakestFriend:
        hero.say('Hey ' + weakestFriend.id + ', go home!')