# \[Solved\] Help with aggressive mimicry

**URL:** <https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658>\
**Category:** Uncategorized\
**Created:** [October 11, 2017, 5:07pm UTC](https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658 "2017-10-11T17:07:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajdv](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@ajdv](https://discourse.codecombat.com/u/ajdv)\
**Post date:** [October 11, 2017, 5:07pm UTC](https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658/1 "2017-10-11T17:07:45Z")

</div>

this is my code

```python
# Protect the village from the ogres. 
# Watch for ogres, peasants and ogres disguised as ”peasants".

# This function checks if the text starts with the word.
def startsWith(text, word):
    # If the word is longer then the text:
    if len(word) > len(text):
        return False
    # Loop through the indexes of word and text.
    for index in range(len(word)):
        # If characters with the same index are different:
        if word[index] != text[index]:
            # Then the word doesn't coincide with the text.
            return False
    # We checked all letters and they are the same.
    return True

ogreNameStart = "Zog"

while True:
    enemy = hero.findNearestEnemy()
    suspect = hero.findNearest(hero.findFriends())
    # Use the function "startsWith" to check
    # if suspect's name (id) starts with "Zog", attack:
    if suspect (id) startsWith "zog":
        hero.attack(enemy)
    else:
        if enemy:
            hero.attack(enemy)
        else:
            hero.move(27,27)

    

```

and it wants me to add a : after

````python
  if suspect (id) startsWith "zog":```
````

---

<div class="post-metadata">

**Author:** ![SuperSmacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/supersmacker/32/8385_2.png) [@SuperSmacker](https://discourse.codecombat.com/u/SuperSmacker)\
**Post date:** [October 11, 2017, 8:58pm UTC](https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658/2 "2017-10-11T20:58:59Z")

</div>

> [@ajdv](#):
>
> if suspect’s name (id) starts with “Zog”, attack:

That doesn’t LITERALLY mean write if suspect (id) startsWith “zog”  
It means to utilize the startsWith function defined before.

---

<div class="post-metadata">

**Author:** ![ajdv](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@ajdv](https://discourse.codecombat.com/u/ajdv)\
**Post date:** [October 16, 2017, 6:26pm UTC](https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658/3 "2017-10-16T18:26:19Z")

</div>

i tried this but my hero wont realise that its an ork until it revels its self

```python
# Protect the village from the ogres. 
# Watch for ogres, peasants and ogres disguised as ”peasants".

# This function checks if the text starts with the word.
def startsWith(text, word):
    # If the word is longer then the text:
    if len(word) > len(text):
        return False
    # Loop through the indexes of word and text.
    for index in range(len(word)):
        # If characters with the same index are different:
        if word[index] != text[index]:
            # Then the word doesn't coincide with the text.
            return False
    # We checked all letters and they are the same.
    return True

ogreNameStart = "Zog"

while True:
    enemy = hero.findNearestEnemy()
    suspect = hero.findNearest(hero.findFriends())
    # Use the function "startsWith" to check
    # if suspect's name (id) starts with "Zog", attack:
    if startsWith:
        if enemy:
            if hero.isReady("chain-lightning"):
                hero.cast("chain-lightning", enemy)
            else:
                
                hero.attack(enemy)
        else:
            hero.moveXY(27,27)

```

theres nothing wrong with the code exsept for the fact thai its faleing

---

<div class="post-metadata">

**Author:** ![ajdv](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@ajdv](https://discourse.codecombat.com/u/ajdv)\
**Post date:** [October 16, 2017, 6:32pm UTC](https://discourse.codecombat.com/t/solved-help-with-aggressive-mimicry/12658/4 "2017-10-16T18:32:43Z")

</div>

nvm i got it thank you
