Help me complete this level

please help me complete this level:
Level 7,Wood Forest
thks
why my hero is died?
2021-08-10T04:04:00Z

hey can you give the specific level like Nine gems example.

Welcome to the forum! This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.
Have a great time! :partying_face:

Can you please post your code? And then we will be able to help you. Thanks!

1 Like

while true:
enemy = hero.findNearestEnemy
if enemy:
hero.isReady(“cleave”)
hero.cleave(“enemy”)
else:
hero.attack(“enemy”)

Why does the 2nd time hero have to wait to cleave??

I noticed several problems:

  1. In the enemy variable, you forgot the () after hero.findNearestEnemy
  2. isReady() is a function that returns true or false. When you use isReady on it’s own, it means nothing. You need to use it in a if like if hero.isReady("cleave"): so it checks if isReady("cleave") is true.
  3. The if/else says if there’s an enemy, cleave, else, attack. It should be
if enemy:
   if hero.isReady("cleave"):
       cleave
   else:
       attack
1 Like

No, at their level, it shouldn’t be that code yet.

@Khoa_Tr_n, you are not indenting your code whatsoever. You must indent everything after while true:, if enemy And else.
I think your code is perfect. You just need to indent it.

When you don’t format your code, it doesn’t indent.

Ok.
Can you please format your code using the </> button. This way we can see your code in full.

@Khoa_Tr_n

image

After you click that paste your code!

1 Like