Passing through-backwoods forest help

I need help in this level whenever i put this code only my hero would movie not my pet wolf

while True:
    item = hero.findNearestItem()
    if item:
    # If item.type IS NOT EQUAL TO "gem"
        # Then follow your pet wolf.
        hero.moveXY(pet.pos.x, pet.pos.y)
    # Else:
        if item == “gem”:
        # Move to the gem’s position.
        hero.moveXY(item.pos.x, item.pos.y)

If the item does not equal gem, then follow the wolf. Otherwise, if the item is a gem, then move to its position.

if item:
    if item.type != "gem":
        #move with your pet
        #move to the item