Towers of Hanoi


#1

Hi,

I arrived at the Towers of Hanoi project in the Python course. I’m a beginner so it’s really difficult to finish this exercise without any provided solution / video walkthrough which was the case for previous projects.

Is someone willing to share the full solution with me? Thank you.

https://www.codecademy.com/paths/computer-science/tracks/linear-data-structures/modules/cspath-stacks/projects/towers-of-hanoi


#2

Follow-up question.

In step 14 you need to provide the following list comprehension.

choices = [stack.get_name()[0] for stack in stacks]

What is the purpose of “[0]” please?


#3

stack is a list. The [0] is the index number in stack you are referencing.


#4

my completed code is here: https://gist.github.com/cd0ef5b56a757260ce2245c884069ccb


#5

Thank you man for the solution