def tower_of_hanoi(n, source, auxiliary, destination):
    if n == 1:
        print("Move disk 1 from source", source, "to destination", destination)
        return
    tower_of_hanoi(n-1, source, destination, auxiliary)
    print("Move disk", n, "from source", source, "to destination", destination)
    tower_of_hanoi(n-1, auxiliary, source, destination)

n = int(input("Enter the number of disks: "))
tower_of_hanoi(n, 'A', 'B', 'C')

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: