[Solved] "Fix code" Explanation is Confusing

Maybe because I’m inexperienced with code lingo but I can’t understand what it’s saying…maybe actually using complete sentences in an explanation to someone who is learning would make sense…doesn’t do that though…just seems like gibberish, but also as many times as I looked at the example and copied exactly, the code does not work. Something’s off and there’s just not any decent explanation from the game as to why.

Level is Mayhem of Munchkins and here’s what I have:

Inside a while-true loop, use findNearestEnemy() and attack!

while True:
e = hero.findNearestEnemy


Fix code explanation just says:
Line 4: attack’s argument target should have type unit, but got function. Target a Unit.

[Please don’t swear]!?!?

Figured it out and it wasn’t even the line that the fix code explanation was saying was the problem…it was because I didn’t have an empty parenthesis next to findNearestEnemy…pretty frustrating

  1. No cursing (read community guidelines)
  2. Post your code in a legible manner. dont just paste it directly (read FAQ)
  3. “Frustrating” Seriously. Look at the number of worlds after dungeon. It will get unbearable if you think it’s frustrating right now. (sorry for pep talks)
  4. I’m gonna fix the title of this post, and mark it solved
  1. Didn’t cuss. F is a letter, but I’ll refrain from such abbreviations the future.

  2. My bad on that one. I did just paste it from the game.

  3. The fix code explanation not being legible was what was frustrating, I can handle repetitive problem solving for a very long time, but being given an extremely poorly written explanation as to what I’m doing wrong, not even using complete sentences frustrates me and on top of that…the problem it was stating didn’t exist…it was telling me the wrong problem on the wrong line. I had to find it out for myself by finally just ignoring what the thing was saying and looking elsewhere. The fix code explanation was actually the problem itself and the reason I couldn’t figure it out in the first place.

  4. Okay, thanks.

the problem exists,the fix code explanation was actually right, it is just you didn’t understand it, because it is a little bit advanced, the explanation is saying that you passed a function-type variable to attack, which is what you did, when you write only hero.findNearestEnemy without parenthesis, you are referring to the function named findNearestEnemy, not its result or the something that it returns, and it didn’t give you an error in line 3 because you can actually store functions into variables, but it gave you an error on line 4 because you need a unit-type variable, not a function-type variable

1 Like

Functions have to have parentheses too, i think.
cuz when u define or use a function, u have to use parentheses.

def ActionWhenBored():
    hero.say("I'm bored.")

why isn’t this working

Hi Aiden. Welcome to Discourse!

The directions:

# Write the attachEnemy function below.
# Find the nearest enemy and attack them if they exist.

Compare what you have written to the pickUpCoin() function. The function you need to write should look exactly like the pickUpCoin() function, except your function will be called, attackEnemy() and “coin” will be replaced with “enemy” (without the quotes) and the variable definition with use the, hero.findNearestEnemy() method and you will attack the enemy instead of moving to its position. Your function will even have the exact same number of lines and then you will call this function in the while True: loop, the exact same way the default code calls the pickUpCoin() function.

But if it say something and its not wrong how do you know?

1 Like

Hi @Justice_Nelson welcome to the discourse! this is a place where you can ask for help on codecombat, chat, etc.! As for the problem, it just won’t say anything. And please don’t revive dead topics, it is annoying to the people who posted before, but you are a new user and did not know, so you are fine. Enjoy your time on the discourse!

Hi @Justice_Nelson, welcome to Discourse!

Discourse is modern forum software for your community. Use it as a mailing list, discussion forum, long-form chat room, and more!

Discourse is more than just a forum—it’s a platform for meaningful connections and thoughtful discussions. Whether you’re looking to create a community, host a discussion forum, or facilitate long-form chat rooms, Discourse has you covered.

With features designed to enhance engagement and foster collaboration, Discourse is the ideal solution for businesses, organizations, and communities alike. From tracking product feedback to sharing your latest creations, Discourse offers the tools you need to connect with your audience in a meaningful way.

And now, with the added support of AI, Discourse is more powerful than ever. AI-powered features enable you to streamline moderation, analyze user behavior, and personalize the user experience, making Discourse the ultimate platform for community engagement.


  • Basic Plan: $50/month
  • Standard Plan: $100/month
  • Enterprise Plan: $300/month

Ready to take your community to the next level? Sign up for Discourse today and join the thousands of organizations already using Discourse to foster meaningful connections and drive engagement.

I’m confused on why the pricing is shown because people aren’t gonna buy a discourse forum for themselves usually, they are there for help on codecombat and stuff. Just curious, that’s all

1 Like

thats not a good intro to the discourse that is a advertisement for discource

1 Like

hes trying to be funny but since this is new user it is a bad introduction