I need a little help in order to understand smth


#1

Hello guys!
The last “else” doesn’t seem to work and I don’t understand why. It says “unexpected token” - fix your code.
Doesn’t the bash attack have a cooldown, just like the cleave attack?


def attack:
    if enemy:
        if self.isReady("cleave"):
            self.cleave(enemy)
        else:
            if self.isReady("bash"):
                hero.bash(enemy)
        else:
            hero.attack(enemy)

#2

There should be no more than one else for each if. For Python you can use elif statement and else will be the final one:

if a > 0:
    hero.say("It's positive")
elif a < 0:
    hero.say("It's negative")
else:
   hero.say("One option else - zero")

#3

I get it now, seems reasonable. Thanks!