Learn Recursion by Solving the Tower of Hanoi Puzzle - Step 4

Tell us what’s happening:

Im getting a KEY error ‘A’ on my print function line. Why?

Your code so far


# User Editable Region

rods = {
     type(['A']): range(3, 0, -1),
    'B': [],
    'C': []
}
print(type(rods['A']))

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Learn Recursion by Solving the Tower of Hanoi Puzzle - Step 4

It sounds like there is a problem with one of the keys in your object.

You are trying to access the key ‘A’

print(type(rods['A']))

But if you look at your object, it no longer has a key called ‘A’

So just the literal replacement that is already in the line that’s next to the ?

Now I have this rods = { type(['A']): range(3, 0, -1), 'B': [], 'C': [] } print(type,('A'))

You had it exactly right the first time. Except you’ve changed the name of the key in the object and it’s still no longer ‘A’.

So I got rid of the ‘A’ but still says I need to pass ‘A’ to the type function()?

     type(['A']): range(3, 0, -1),
    'B': [],
    'C': []
}
print(type(rods))

Reset the step, and don’t make any changes to the object that’s already created.

Your print() was correct the first time.