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

Need help on Friend and Foe

#1

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”)

#2

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

#3

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

#4

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

#5

Post your code please