Towers of Hanoi Possible Bug?


So, I’ve been stuck on this for over 5 hours and I’ve started over from scratch a few times. It is telling me there is an attribute error, but I clearly have it typed out fine. Here is my code and a screenshot.

from stack import Stack

print("\nLet's play Towers of Hanoi!!")

#Create the Stacks
stacks = [ ]
left_stack = Stack("Left")
middle_stack = ("Middle")
right_stack = ("Right")


#Set up the Game
num_disks = int(input("\nHow many disks do you want to play with?\n"))

while num_disks < 3:
  num_disks = int(input("Enter a number greater than or equal to 3\n"))

for disk in range(num_disks, 0, -1):

num_optimal_moves = (2 ** num_disks) - 1
print("\nThe fastest you can solve this game is in {num_moves} moves.".format(num_moves = num_optimal_moves))

#Get User Input
def get_input():
  choices = [stack.get_name()[0] for stack in stacks]
  while True:
    for i in range(len(stacks)):
      name = stacks[i].get_name()
      letter = choices[i]
      print("Enter {letter} for {name}.".format(letter = letter, name = name))
    user_input = input("")
#Play the Game


Hi @chiefyogiblak,

In the first of the three lines copied below, you assigned a Stack to the left_stack variable:

left_stack = Stack("Left")
middle_stack = ("Middle")
right_stack = ("Right")

But what did you assign to middle_stack and right_stack?


■■■■! Haha! I see my mistake now that you pointed it out. After coding a while, us programmers get tunnel vision and don’t see the errors right away.

I sat and studied (stared, really) the code for hours! Thank you!