[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

1 Like

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

2 Likes

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

1 Like

thanks! :smile: :partying_face:

1 Like

Here put

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

Here put

h=findFriendByName(wereyeti)
1 Like

Here put
wereName

Instead of wereNames put wereName.
Does it work now?

1 Like

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?

1 Like

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

1 Like

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

1 Like

Here put

wereName.trim()

Does it work now?

1 Like

yes it does. thanks @AnSeDra! :partying_face:

2 Likes

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

1 Like