I am in the Python mode of code combat. I am stuck on the Final Kithmaze level. This is the code I put, but it won’t work. I’d appreciate a little help. Thanks!
calling find nearest enemy will return the nearest enemy at the time that you call it, so enemy1 enemy2 and enemy3 will all equal whatever enemy was nearest at the start of the level. Is this what you intended?
(hint: use 3 backticks (the ` on the ~ key) around code to make it format nicely, especially when the indentation matters)
If that’s the case, you’re telling your hero to make all those moves, attack all three of those variable thangs at the end of the moving, and then do it all over again starting with the moves.
Also, @Yaur is right that all three of your enemy variables will be the same thang.
To put something inside the loop in Python you have to indent it.
So…
loop:
self.moveRight()
self.say("Look at me walking!")
self.say("Not walking now!")
The two indented lines are inside the loop and will be executed over and over in sequence. The last line actually never gets executed because it is outside of the loop and the code never comes out of the loop. Don’t worry about that too much as it will be explained later. Just know that Python determines what’s inside a loop by how far it’s indented. Everything has to line up.