As you can read in the FAQ, you can format your code correctly in posts by placing three backticks (`) before and after your code. Or, you can highlight it, then click the “</>” button.
You can’t cleave every enemy because the “cleave” command has a specific cooldown of ten seconds. Instead of attacking if the distance is more than five meters, try checking to see whether you are ready to cleave; if you aren’t, then attack, as it says in the comments in the code when the level first starts:
# Find the distance to the enemy with distanceTo.
# If the distance is less than 5 meters...
# ... if "cleave" is ready, cleave!
# ... else, just attack.