Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

How do you close a function?

def getEnemyX():
# Complete this function.

pass

while True:
enemyX = getEnemyX()
if enemyX > 0:
hero.say(enemyX)

@STEPHEN_GRELL which level are you in?

I have a few things to say, firstly, as @slime_bunny_222 said: what level are you on? Secondly: please could you give more information about your problem. What do you mean when you say ‘close’? Do you mean complete the function as it says here?:

Finally, please could you fully format your code, you’ve only formatted one line at the moment. You can look at this topic for a refresher:
How to Post Your Code With Radiant, Harmonious Formatting
Thanks
Danny

I’m on the level Ogre Invaders
This is my code:

Fill the getEnemyX function so that it finds an enemy and returns its X position. If there is no enemy, return -1.

def getEnemyX():
# Complete this function.
enemyX = hero.findNearestEnemy() <—I added that because I thought that’s how you do that
pass

while True:
enemyX = getEnemyX()
if enemyX > 0:
hero.say(enemyX)