h1,2,3 but can not see these values in a debugger

    def hanoi(n,s,t,b):
        assert n > 0
        if n == 1:
            print ('move',s,'to',t)
    for i in range(1,5):
        print ('New Hanoi Example: hanoi(',i,',source, target, buffer)')
        print ('----------------------')

Open in new window

I tried to give values h1,2,3 but can not see these values in a debugger

this is so I can see moving parts
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I don't really understand your question.

The code seems working and if you single step INTO the function you should be able to see n,s,t,b

What exactly does not work?

You could just set a breakpoint at line 3. and inspect n,s,b,t

or just insert following line after line 1 of your code. That's of course not using a debugger, but just adding traces, but sometimes this is faster and more efficient then singlestepping through code.
    print("%2d %10s %10s %10s" % (n, s,t,b))

Open in new window

The formatting in the print statement is just there to have the columns aligned

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Walter RitzelSenior Software EngineerCommented:
According to your algorithm, h1, h2 and h3 will never have a value, because your hanoi function does not return a value.
Also, you are print the movement only when n=1, which seems odd. Double check your logic on this piece.
rgb192Author Commented:
print statement and

h1,2,3 never return a value.
The implementation is doing what it's supposed to do.

However as Walter stated. h1, h2, h3 will always be none.
and are not needed, so you could rewrite the code as

Open in new window

as the recursive calls without value assignments are sufficient

The whole idea of towers of Hanoi ( http://en.wikipedia.org/wiki/Tower_of_Hanoi ) is to move a disk only when n is 1.
the recursive calls and the fact that permutations are performed over s,t,b  are 'just' there to determine the order of the moves.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.