Hi I am stuck on the Tower of Hanoi project.
Whenever I try to run the script using python3 -c ‘import script; script.get_input()’ in bash I get this error → AttributeError: module ‘script’ has no attribute ‘get_input’
But, i’ve clearly defined the get_input function in the program. Any help would be appreciated!
CODE BELOW:
from stack import Stack
print("\nLet’s play Towers of Hanoi!!")
#Create the Stacks
stacks =
left_stack = Stack(“Left”)
middle_stack = Stack(“Middle”)
right_stack = Stack(“Right”)
stacks += [left_stack, middle_stack, right_stack]
#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):
left_stack.push(disk)
num_optimal_moves = (2**num_disks) - 1
print("\nThe fastest you can solve this game is in {0} moves".format(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 {0} for {1}".format(letter, name))
user_input = input("")