Tell us what’s happening:
My print command is not passing. Incorrect format.
I deleted rods, created the variables, and changed the arguments. The function works as it’s supposed to but the print command format is incorrect. I’ve tried many different permutations. I’d love some help
My print command is:
print(f"A: {A}, B: {B}, C: {C}\n")
The prompt says “You should modify your print() call to print A, B, C, instead of the rods (dictionary) object. Keep the newline character at the end of the print() command.”
In an earlier version, I still had source, auxiliary, and target as the arguments and variables within the function, but I’ve been trying everything I can possibly think of that might fix the error. The other forum posts were helpful but I was not successful in correcting my code.
Your code so far
# User Editable Region
NUMBER_OF_DISKS = 4
A = list(range(NUMBER_OF_DISKS, 0, -1))
B = []
C = []
def move(n, A, B, C):
if n > 0:
# move n - 1 disks from A to B, so they are out of the way
move(n - 1, A, C, B)
# move the nth disk from A to C
C.append(A.pop())
# display our progress
print(f"A: {A}, B: {B}, C: {C}\n")
# move the n - 1 disks that we left on B onto C
move(n - 1, B, A, C)
# initiate call from A to C with B
move(NUMBER_OF_DISKS, A, B, C)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Challenge Information:
Learn Recursion by Solving the Tower of Hanoi Puzzle - Step 52