Arcane Ally Level - Wrong Code?


#1

Hello Everyone! I am stuck in this level… I really don´t know what´s my code´s problem here:

I would really apreciate any help ^^
Thanks!


#2

It’s best to get in the habit of checking to see if there is an enemy first, before cleaving or attacking, because if there is a moment of time when no enemy is present, the code fails.


#3

I think that´s not the problem… check out the “fix code” message:

But thanks to replying ^^


#4

Oh wait, I kinda got it… but how could I write it correctly?


#5

what I said before is exactly the problem and that’s what the null means - there is no enemy. You just need to put

if enemy:

after the variable enemy that you have defined and tab everything after it over.

Summary
if enemy:
    if hero.isReady("cleave"):
        hero.cleave(enemy)
    else:
        hero.attack(enemy)

Memorize this because you’re going to be doing it a LOT.


#6

Oh, sorry :sweat_smile:, now I really got it! :
I really apeciate your answer :slight_smile:
I don´t understand 100% of english but i´m trying to


#7

What language do you know?


#8

He’s using python (20 char)


#9

I mean language as in english spanish and ect. :sweat_smile: My bad I didn’t describe.