The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Error in python code

Error in python code

0
Votes
1
Answer

count = 0
def towers_of_honoi(A,B,C,n):
global count

if n == 1:
disk = A.pop()
C.append(disk)
count += 1
else:

tower_of_honoi(A,C,B,n-1)
tower_of_honoi(A,B,C,1)
tower_of_honoi(B,A,C,n-1)
return count
 
error is A not defined

1 Answer

365 Team
0
Votes

Hi Viraj, 
thanks for reaching out! You need to define A, B and C, which represent the towers we want to stack. Try the following code before the def towers_of_hanoi:
A = [3,2,1]
B = []
C = []
 
Best,
Eli