I’m at the end of the first level (Kithgard’s Dungeon) but I’m still having trouble with the While True Loop. Whenever I use one to have a cleaner code, whatever I write after it (without the 4 spaces in front of it) won’t play!
So what is the code to make it stop when let’s say the enemy is defeated? Is there a code for this? I’d really love to implement this use, but I can only use it once and at the end in order for everything to work! It’s bothersome.
For example, this code wouldn’t work:
while True: enemy1 = hero.findNearestEnemy() if enemy1: hero.attack(enemy1) hero.moveRight()
The character would just stand there, idling.
I hope you can help me. I’m new to coding but I already love it!
Thank you very much.