backwoods standoff i cannot beat it
i got to this how i need help hero.cleave(enemy)
enemy = hero.findNearestEnemy()
hero.attack(enemy)
if enemy:
enemy = hero.findNearestEnemy()
if enemy:
while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if hero.isReady(“cleave”):
# Cleave!
hero.cleave(enemy)
# Else, if cleave is not ready:
else:
enemy1 = hero.findNearestEnemy()
Please take a look at the link below and format your code properly. It helps us see the structure of your code.
Also give greater detail about what exactly isn’t going right. How To Post/Format Your Code Correctly
I think I see the problem though. You need an if enemy loop in your code, otherwise your hero might try to attack an enemy that doesn’t exist, which will cause a major error.
Just to make sure, is this level Backwoods Standoff?
Taking a look at this level, the if enemy check that @codingstudent suggested shouldn’t cause an issue, but is still very good practice.
If your code is properly indented it essentially works, so we do need to see it in the correct format to help with this one.
One a side note, I see you found another enemy in your else statement that isn’t needed. In this case, the if statement is checking the type of attack you want to use against that one enemy. If I can cleave, do that; but if I can’t, use the regular attack. You still want to attack the original enemy you found in the else statement so you don’t need to find a new enemy enemy1.