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

Tell us what’s happening:

I can not generate the list counting down from 3 to 1 with range. What is the problem ? Thank you.

Your code so far


# User Editable Region

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

# 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/132.0.0.0 Safari/537.36

Challenge Information:

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

What sort of thing does the range() function return?

1 Like

You’re very close! range already returns a list, which you’ve put in another list.

So what you end up with is [ [3, 2, 1] ].

EDIT: :snail:

2 Likes

It is supposed to generate a sequence of numbers counting from 3 to 0.

Right though that wasn’t quite what I was getting at. Specifically the “sort of thing” returned is a list. You don’t usually put a single list inside of a list.