Is it code error or is the heroes losing because lack of armour?
no (characters 20000000000)
hey I still there @weary
um I still need help @weary because I can not figure this out
hey can anyone help me out @DanTDM_4
help please @Chaboi_3000
hey I need help because no one else seems to be helping me @dedreous
enemies = hero.findEnemies() enemyIndex = 0 while enemyIndex < len(enemies): enemy = enemies[enemyIndex] if enemy: if enemy.type != "sand-yak": while enemy.health > 0: hero.attack(enemy) enemyIndex += 1 hero.moveXY(40, 31)
Hmm, I thought you said it worked. Please don’t @ loads of people. Someone will reply eventually and you don’t need to send loads of notifications for nothing.
Why have you removed the main while True loop which goes around the whole code. It should’ve been there at the start.
If you put that back in it will work.
oh sorry did not know about that @ but the first person told me to remove it so I will do that
while True: enemies = hero.findEnemies() enemyIndex = 0 while enemyIndex < len(enemies): enemy = enemies[enemyIndex] if enemy: if enemy.type != "sand-yak": while enemy.health > 0: hero.attack(enemy) enemyIndex += 1 hero.moveXY(40, 31)
but on line 7 it tells me that there is an empty if statement
If that’s the indentation you have in the level then it won’t work. Inside a while loop you must indent 4 spaces forwards, in fact after any statement with a : you must indent that 4 spaces.
i did that and now it is showing a error of where it is showing the code never finished or to slow
Please could you send a screenshot of the level.
You’ve now indented the if enemy backwards. You want to indent it forwards. It should be within the second while loop should in not?
I put the if enemy in the second while true but it keeps saying code is either really slow or infinite loop
Indent line 13 (ie add 4 spaces) so it’s inside the while loop (on line 6).
thank you that worked for me and I won the level for real this time