# The one wizard help

**URL:** <https://discourse.codecombat.com/t/the-one-wizard-help/17493>\
**Category:** Level Help\
**Created:** [February 14, 2019, 2:18am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493 "2019-02-14T02:18:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![underboy](https://avatars.discourse-cdn.com/v4/letter/u/a5b964/32.png) [@underboy](https://discourse.codecombat.com/u/underboy)\
**Post date:** [February 14, 2019, 2:18am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/1 "2019-02-14T02:18:11Z")

</div>

Is there something wrong with my code?

```python
# Defeat as many ogres as you can.
# Use 'cast' and 'canCast' for spells.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.canCast("chain-lightning"):
            hero.cast("chain-lightning", enemy)
    elif enemy:
        if hero.canCast("lightning-bolt"):
            hero.cast("lightning-bolt", enemy)
    else:
        hero.moveXY(28, 16)

```

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [February 14, 2019, 2:58am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/2 "2019-02-14T02:58:59Z")

</div>

Why are you using elifs and ifs to check for an enemy? Merge those two into one if statement

---

<div class="post-metadata">

**Author:** ![Red-backspider](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/red-backspider/32/23212_2.png) [@Red-backspider](https://discourse.codecombat.com/u/Red-backspider)\
**Post date:** [January 28, 2021, 4:13am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/4 "2021-01-28T04:13:08Z")

</div>

Try using `hero.cast("root", target)` and then killing the `target` by using `hero.attack(target)`

---

<div class="post-metadata">

**Author:** ![Red-backspider](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/red-backspider/32/23212_2.png) [@Red-backspider](https://discourse.codecombat.com/u/Red-backspider)\
**Post date:** [January 28, 2021, 4:14am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/5 "2021-01-28T04:14:29Z")

</div>

is this solved? it was created on the 19th of february 20 **19**!!!

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 28, 2021, 4:15am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/6 "2021-01-28T04:15:11Z")

</div>

Yes probably, please don’t revive dead topics, underboy is not active anymore so you just wasted you post.

---

<div class="post-metadata">

**Author:** ![Red-backspider](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/red-backspider/32/23212_2.png) [@Red-backspider](https://discourse.codecombat.com/u/Red-backspider)\
**Post date:** [January 28, 2021, 4:17am UTC](https://discourse.codecombat.com/t/the-one-wizard-help/17493/7 "2021-01-28T04:17:22Z")

</div>

i noticed after i rplied
