enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex<len[enemies]:
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
enemyIndex+=1
Please could you format your code correctly:
Indentation is very important in while loops, and it may be the problem in your code.
Danny
Alrigty! Sorry for any inconviniences!
I cant quite work out why this wont do the trick.
I think @Deadpool198 is right and the point is about indentation in part enemyIndex+=1
Wouldn’t you be so kind to provide direct link to the level?
Try len(vars)
instead of len[vars]
And then delete your code from the post)
still does not work, I am confused
I copipasted your code and changed only len[enemies] to len(enemies) and it worked.
Really? I cant get it to work.
Please post your new code (formatted) so we can be sure you made the right change.
Danny
Why did you change this line? I didn’t told to do that
Did I? Oops (20 chars)
Even so, it does not work grrr
It is quite confusing to be fair. The python function len() uses brackets. Most python functions do (like str(), int(), Math functions etc.). However when you’re defining enemy you need to use enemies[enemyIndex]. This is because when you’re accessing a specific element of an array you put a number inside the .
Please post your code again.
Danny
Omg.
Now I copy the last your version of code and change only enemy = enemies(enemyIndex)
to enemy = enemies[enemyIndex]
and it work. (again)
And now the last one is OK. Is there any warnings about errors?
Nope, just says ran out of time
Your most recent code works fine for me. (Alex was probably replying at the same time as you). Please post screenshots of the level screen and of your equipment. Gear can often cause issues.