This is a new forest level Mail Interceptor
The level is a practice about functions, also I wanted to “fill” the gap before “Short-sighted Burl”
This is a new forest level Mail Interceptor
The level is a practice about functions, also I wanted to “fill” the gap before “Short-sighted Burl”
Nice level about method arguments and functions Level requires limited-range glasses though, didn’t realize that until a while later.
Thanks. “Twilight glasses” and “Enchanted lenses” is a pain for the forest levels If I will see more problems with it from beginners then I will limit it (We’re trying not to limit it)
Hello,
I keep getting a “Ran Out of time error” on this level when I ‘Submit’, but it says “Success!” when I ‘Run’ the code.
Please find my code below:
def ambushAttack(target):
# Attack the target if it exists and return to the mark.
# Write the function:
if ogre:
hero.attack(ogre)
else:
hero.moveXY(52, 37)
pass
while True:
ogre = hero.findNearestEnemy()
ambushAttack(ogre)
I tried different variations of this replacing “ogre” with target and it keeps giving me the same error.
Thanks in advance.
@nicolares20 welcome!
First, you’d want to indent the if/else statements. Then replace the ogre
with target inside the ambushAttack function. So you’d be getting this:
def ambushAttack(target):
# Attack the target if it exists and return to the mark.
# Write the function:
if target:
hero.attack(target)
else:
hero.moveXY(52, 37)
pass