Level help please on Backwoods Standoff python

@ducky @CodingGeek14 @PythonCoding
please help me

# Munchkins are attacking!
# The swarms will come at regular intervals.
# Whenever you can, cleave to clear the mass of enemies.

while True:
    enemy = hero.findNearestEnemy()
    # Use an if-statement with isReady to check "cleave":
    if enemy:
        ready = hero.isReady("cleave")
        # Cleave!
        hero.cleave(enemy)
    # Else, if cleave is not ready:
    hero.attack(enemy)
    hero.attack(enemy)
        # Attack the nearest ogre!
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)        

this is python and i need help because i am stuck on this level

I think you should either continue JavaScript or start from the beginning with python, because if you start from the middle in any coding language, you’ll get confused.

2 Likes

Actually, ducky has a very good point here. I was trying to figure out how to explain syntax, but ducky nailed it!

Hold on, @ZAX155, I’ll help you

I think your problem is in this final piece of code:

You need to change the enemy in enemy = hero.findNearestEnemy to enemy1 as well as in both of your hero.attack(enemy) lines, @ZAX155

@ZAX155, actually, there are several problems, most being syntax issues.

First, the proper way to see if the hero is ready to cleave, is to add the isReady to the if statement…like:

    if enemy and hero.isReady("cleave"):

Second, the else statement is missing from the if block.

Third, as presented (shown) above, the final three lines will never run, as they are outside of the while True loop.

1 Like

You actually don’t need the last three lines. They are useless. All you have to do is to put the isReady into the if statement, as @dedreous said, add an else statement to the if enemy statement, and put your hero.attack(enemy) lines into the else statement.

That is an extremely good point, @ducky

go here https://discourse.codecombat.com/t/official-clan-list/3575

ok i will (20 chars)

sorry @Deadpool198 i forgot about the one month thing

can someone please close this please @moderators