Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Friend or foe help

I know there are same topics with my problem I looked at them but I couldn’t figure out the answer please help!

while True:
    friend = hero.findNearestFriend()
    if friend:
        hero.say("To battle, " + friend.id + "!")
    # Now find the nearest enemy and tell them to go away.
    else:
        enemy = hero.findNearestEnemy()
        hero.say("Go away, " + enemy.id + "!")

My problem is that my hero doesn’t tell the orges to go away. I also tried to code so that my hero toll the villagers/ peasant to attack, but that didn’t work either. It probably is some silly mistake that I made but I can figure it out.
Thanks if you could hint me something!

Put

with

and use elif enemy:.

thats what i did enemy.id

If you’ve created a topic about a certain subject, please could you not reply on a similar one.
Thank you very much.
:lion: :lion: :lion: