I need a code for the Free Billy challenge on CS2 (Computer Science)
This is my original code:
while True:
enemy = hero.findNearestEnemy()
if hero.isReady(“cleave”):
hero.cleave()
hero.distanceTo(enemy)
else:
if distance < 5:
hero.ta
else:
hero.attack(“Door”)
The part I’m having trouble with is the distance. BTW the language is Python
you didn’t say what distance
is. clarify by assigning distance
with hero.distanceTo(enemy)
.thus, you didn’t check if the enemy exists (if
statment). and, what is hero.ta
?
These are my directions: # Free the wild burl from the ogres!
If “cleave” is ready, then use it.
Else if the distance to an enemy less than 5, then attack it.
Else attack the “Door”.
When I try to put in elif distance < 5: it said try hero.distanceTo()
oh, and format your code properly by putting in ``` twice, between the code.
but first, you have to see if the enemy exists before all that.
Is that bad? I don’t see why
I picked it when I joined CodeCombat.
I’m in a classroom for school, so when I joined it took me to a page where I had at least 6 choices of characters.
And you can still change it.
Oh okay
you didn’t check if the enemy exists. you can’t check the distance without checking if it exists.
I’m also in need of help with this
Welcome welcome to the forum! It is a lovely place where you can share all kinds of stuff (appropriate of course), share bugs, and even get assistance for code! We suggest that you review this topic which shows all essentials of this board! And we suggest you review this topic which shows how to post your code correctly! Thanks!!

Please post your code formatted correctly.
Lydia