# \[SOLVED\] Ice Hunter - Python

**URL:** <https://discourse.codecombat.com/t/solved-ice-hunter-python/20859>\
**Category:** Level Help\
**Created:** [April 7, 2020, 8:20pm UTC](https://discourse.codecombat.com/t/solved-ice-hunter-python/20859 "2020-04-07T20:20:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Code\_Kid13](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_kid13/32/11686_2.png) [@Code\_Kid13](https://discourse.codecombat.com/u/Code_Kid13)\
**Post date:** [April 7, 2020, 8:20pm UTC](https://discourse.codecombat.com/t/solved-ice-hunter-python/20859/1 "2020-04-07T20:20:53Z")

</div>

For some reason, I can only hunt 3 yaks, although it should work. Here’s my code:

```python
def isSubstring(word, substring):
    # We iterate through the start indexes only.
    rightEdge = len(word) - len(substring)
    # Loop through the indexes of the word.
    for i in range(rightEdge + 1):
        # For each of them loop through the substring
        for j in range(len(substring)):
            # Use an offset for the word's indexes.
            shiftedIndex = i + j
            # If letters aren't the same:
            if word[shiftedIndex] != substring[j]:
                # Check the next start index in the word.
                break
            # If it was the last letter in the substring:
            if j == len(substring) - 1:
                # Then the substring is in the word.
                return True
    # We haven't found the substring in the word.
    return False

# Loop through all enemies.
enemies = hero.findEnemies()
for e in range(len(enemies)):
    enemy = enemies[e]
    # Use the function isSubstring to check
    # if an enemy.id contains "bos":
    if isSubstring(enemy.id, "bos"):
        # Then defeat it.
        while enemy.health > 0:
            hero.attack(enemy)

```

I need HELP!

---

<div class="post-metadata">

**Author:** ![Code\_Kid13](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_kid13/32/11686_2.png) [@Code\_Kid13](https://discourse.codecombat.com/u/Code_Kid13)\
**Post date:** [April 7, 2020, 8:23pm UTC](https://discourse.codecombat.com/t/solved-ice-hunter-python/20859/2 "2020-04-07T20:23:46Z")

</div>

Never mind. I resubmitted a couple times and it worked.
