# Leave It To The Cleaver PLS HELP PLS

**URL:** <https://discourse.codecombat.com/t/leave-it-to-the-cleaver-pls-help-pls/20278>\
**Category:** Level Help\
**Created:** [February 14, 2020, 7:04pm UTC](https://discourse.codecombat.com/t/leave-it-to-the-cleaver-pls-help-pls/20278 "2020-02-14T19:04:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Musa\_Haider](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/musa_haider/32/11430_2.png) [@Musa\_Haider](https://discourse.codecombat.com/u/Musa_Haider)\
**Post date:** [February 14, 2020, 7:04pm UTC](https://discourse.codecombat.com/t/leave-it-to-the-cleaver-pls-help-pls/20278/1 "2020-02-14T19:04:12Z")

</div>

my code is # The function defines a parameter called `target`  
def cleaveWhenClose(target):  
if hero.distanceTo(target) \< 5:  
pass  
# Put your attack code here  
# If cleave is ready, then cleave target  
hero.cleave(enemy)  
# else, just attack `target`!  
if enemy:  
enemy = hero.findNearestEnemy()  
hero.attack(enemy)

# This code is not part of the function.

while True:  
enemy = hero.findNearestEnemy()  
if enemy:  
# Note that inside cleaveWhenClose, we refer to the `enemy` as `target`.  
cleaveWhenClose(enemy)  
if enemy:  
hero.attack(enemy)  
and i have been on this for a few weeks i am very confused with what i go incorrect pls someone help me(preferably post the answer) Thank you.

---

<div class="post-metadata">

**Author:** ![Musa\_Haider](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/musa_haider/32/11430_2.png) [@Musa\_Haider](https://discourse.codecombat.com/u/Musa_Haider)\
**Post date:** [February 14, 2020, 7:05pm UTC](https://discourse.codecombat.com/t/leave-it-to-the-cleaver-pls-help-pls/20278/2 "2020-02-14T19:05:47Z")

</div>

pls someone answer 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐 🧐

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [February 14, 2020, 10:33pm UTC](https://discourse.codecombat.com/t/leave-it-to-the-cleaver-pls-help-pls/20278/3 "2020-02-14T22:33:42Z")

</div>

Hi Musa…welcome to the forum!

First, please understand that we have members from all around the world, but we aren’t always on the forum. It is possible that someone may not get to your question for as much as 24 hours, or longer. Please be patient.

Second, you need to properly format your code when posted. With out the this formatting, we won’t be able to properly troubleshoot your code. You can learn how to do this here: [[Essentials] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521)

Third, we will not simply provide a solution. However, we will help, guide, answer questions, etc.

Please repost your code, in the proper format, and we’ll work with you from there.
