Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Trojan yeti please help

hi i’ve been trying this code for a while, but i don’t know what’s wrong. here’s the code:

def findFriendByName(name):
    friends = hero.findFriends()
    for i in range(len(friends)):
        if friends[i].id == name:
            return friends[i]
    return None
sergeant = hero.findNearest(hero.findFriends())
wereList = sergeant.wereList
wereNames = wereList.split(",")
for h in wereNames:
    wereyeti = wereNames.trim
    findFriendByName(wereyeti)
    hero.command(h, "move", {"":48, "":47})

thanks for your help

@AnSeDra, could you help me on this level please?

1 Like

Ok. I will try to help you debug your code.

thanks! :smile: :partying_face:

Here put

hero.command(h, "move", {"x":48, "y":47})

Here put

h=findFriendByName(wereyeti)

Here put
wereName

Instead of wereNames put wereName.
Does it work now?

it says that inside the move argument there should be a unit in the unit argument, but it’s null. why?

Can you reshow me your code?

there aren’t any errors but the hero doesn’t do anything. here’s the code:

def findFriendByName(name):
    friends = hero.findFriends()
    for i in range(len(friends)):
        if friends[i].id == name:
            return friends[i]
    return None
sergeant = hero.findNearest(hero.findFriends())
wereList = sergeant.wereList
wereNames = wereList.split(",")
for wereName in wereNames:
    wereyeti = wereName.trim
    h = findFriendByName(wereyeti)
    if h:
        hero.command(h, "move", {"x":48, "y":47})

Can you send me a link to the level?

here:
https://codecombat.com/play/level/trojan-yeti?

Thanks.(20 chars) I will look at my code to refresh my mind with the level.

Here put

wereName.trim()

Does it work now?

yes it does. thanks @AnSeDra! :partying_face:

1 Like

No problem! Glad I could help you! And congratulations for completing the level! :partying_face: