[SOLVED] In My Name, help!

def letterIndex(word, letter):
    
    # Step through each letter as an index of the word.
    while chestIndex < len(ogreLetter):
        
        # Store a character from the word with the current index.
        letterIndex.append(shaman)
        # If it is the required letter:
        if ogreLetter:
            # Then return the current index (number).
            return chestIndex
        # If nothing, return a default value
        else:
            
            return -1

ogreLetter = "z"
shaman = hero.findByType("thoktar")[0]

# Find the index and use it for finding the treasure.
chestIndex = letterIndex(shaman.id, ogreLetter)
hero.moveXY(16 + chestIndex * 8, 36)

This is the error:
image
Lydia

Please send me the link to the level.

Jonathan

In my name
Lydia

Try to replace your function letterIndex(word, letter): with this:

def  letterIndex (word, letter):
    # Step through each letter as an index of the given word
    for index in  range ( 0, len (word), 1 ):
        # Compare the letter in the word with the given letter
        if (word [index] == letter):
            # If it's required letter then return the current index
            return index
    # If nothing, return a default value
    return  0

Jonathan

And replace the ogreLetter with: "z"

Jonathan

Thanks so much!
Lydia

No problem! Anytime!
Congrats on beating the level! :partying_face:

Jonathan

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.