Need help on Friend and Foe

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

Be sure to surround your code in triple back ticks ( ` ) at the top and bottom so it properly formats.

You never define “enemy” in your code: enemy = ...

Can’t attack ! How come?
What should come after the Hero.say("")?

Post your code please

while True:
friend = hero.findNearestFriend()
if friend:
hero.say("To battle, " + friend.id + “!”)
# Şimdi en yakın düşmanı bul ve onlara uzaklaşmalarını söyle.
enemy = hero.findNearestEnemy()
if enemy:
hero.say("To battle, " + enemy.id + “!”)

@JustCombat please don’t give other people answers since you are not suppose to do it. You can give them help and tips but not answers :slight_smile: and the last reply before you was 4 years ago so I suspect they finished it or

do you need help with it? if yes please create a new post and say you need help with it and tell them what is wrong with it :slight_smile:

1 Like

and @JustCombat new time press the </> thing to format correctly :wink:

1 Like