# \[SOLVED\] Please help me on Mad Maxer

**URL:** <https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245>\
**Category:** Level Help\
**Created:** [September 18, 2020, 9:46pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245 "2020-09-18T21:46:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Knight](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gabriel_knight/32/16933_2.png) [@Gabriel\_Knight](https://discourse.codecombat.com/u/Gabriel_Knight)\
**Post date:** [September 18, 2020, 9:46pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/1 "2020-09-18T21:46:39Z")

</div>

please help me on Mad Maxer this is my code

```python
loop:
    farthest = None
    maxDistance = 0
    enemyIndex = 0
    enemies = self.findEnemies()
 
    
    while enemyIndex < len(enemies):
        target = enemies[enemyIndex]
        enemyIndex += 1
 
        
        distance = self.distanceTo(target)
        if distance > maxDistance:
            maxDistance = distance
            farthest = target
 
    if farthest:
        while farthest.health>=0:
            if self.isReady("bash"):
                self.bash(farthest)
            else self.attack(farthest)

```

---

<div class="post-metadata">

**Author:** ![Grzmot](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/grzmot/32/13514_2.png) [@Grzmot](https://discourse.codecombat.com/u/Grzmot)\
**Post date:** [September 18, 2020, 10:09pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/2 "2020-09-18T22:09:18Z")

</div>

Hi @Gabriel_Knight, you have 2 issues with your code. The first one is this:

> [@Gabriel\_Knight](#):
>
> `loop:`

In python, this will never work, what you need to do is have a while loop like this:

```python
While True:

```

The second issue with your code is this:

> [@Gabriel\_Knight](#):
>
> `else self.attack(farthest)`

The indention and placement is wrong. It should look like this:

```python
else:
     self.attack(farthest)

```

Hope this helps!  
Grzmot

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [September 18, 2020, 11:25pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/3 "2020-09-18T23:25:49Z")

</div>

> [@Gabriel\_Knight](#):
>
> `self`

I don’t know if Python will work with self, if it works great! If it doesn’t work, try changing it to

```python
hero

```

And try what @Grzmot said.  
Lydia

---

<div class="post-metadata">

**Author:** ![Grzmot](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/grzmot/32/13514_2.png) [@Grzmot](https://discourse.codecombat.com/u/Grzmot)\
**Post date:** [September 19, 2020, 2:33am UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/4 "2020-09-19T02:33:39Z")

</div>

Yes, self does work in python, but like other people, I just learned to use hero instead, so that’s what I stick with.  
Grzmot

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [September 19, 2020, 4:26am UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/5 "2020-09-19T04:26:57Z")

</div>

Oh ok. I learned Python with hero too, so I was confused.  
Lydia

---

<div class="post-metadata">

**Author:** ![098765432123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/098765432123/32/25850_2.png) [@098765432123](https://discourse.codecombat.com/u/098765432123)\
**Post date:** [September 19, 2020, 2:37pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/6 "2020-09-19T14:37:46Z")

</div>

have u passed the level @Gabriel_Knight?

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [September 21, 2020, 12:39am UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/7 "2020-09-21T00:39:52Z")

</div>

@Gabriel_Knight Have you passed the level?  
Lydia

---

<div class="post-metadata">

**Author:** ![098765432123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/098765432123/32/25850_2.png) [@098765432123](https://discourse.codecombat.com/u/098765432123)\
**Post date:** [September 21, 2020, 1:37am UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/8 "2020-09-21T01:37:48Z")

</div>

if you have please check the box that says solution next to the comment that gave u the answer

---

<div class="post-metadata">

**Author:** ![Gabriel\_Knight](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gabriel_knight/32/16933_2.png) [@Gabriel\_Knight](https://discourse.codecombat.com/u/Gabriel_Knight)\
**Post date:** [September 21, 2020, 3:25pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/9 "2020-09-21T15:25:05Z")

</div>

sorry no I did not pass the level my motem router went out so I could not hop on. sorry for answering so late.

---

<div class="post-metadata">

**Author:** ![Gabriel\_Knight](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gabriel_knight/32/16933_2.png) [@Gabriel\_Knight](https://discourse.codecombat.com/u/Gabriel_Knight)\
**Post date:** [September 21, 2020, 3:27pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/10 "2020-09-21T15:27:33Z")

</div>

also I tried what Grzmot said and it did not work it almost worked though but  
the decoys just got in the way and pushing my character back so I could not attack the ogre thing that can shoot blue stuff.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [September 21, 2020, 3:29pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/11 "2020-09-21T15:29:57Z")

</div>

Could you post your lastest code and can you send me a link to this level?  
Thanks, Lydia

---

<div class="post-metadata">

**Author:** ![Gabriel\_Knight](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gabriel_knight/32/16933_2.png) [@Gabriel\_Knight](https://discourse.codecombat.com/u/Gabriel_Knight)\
**Post date:** [September 21, 2020, 3:30pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/12 "2020-09-21T15:30:48Z")

</div>

wait I just put on the sword of the forgotten and it worked fine.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [September 21, 2020, 3:32pm UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/13 "2020-09-21T15:32:03Z")

</div>

Congrats on solving it!! 🥳 🥳 Don’t forget to do that little tick mark next to the comment that helped you solve this level!

Lydia

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [September 22, 2020, 3:32am UTC](https://discourse.codecombat.com/t/solved-please-help-me-on-mad-maxer/24245/14 "2020-09-22T03:32:08Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
