上手python,练练手
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def hanoi(n,a,b,c):
if n < 0:
print('enter n >0')
elif n==1:
print(a,'-->',b)
elif n > 0:
hanoi(n-1,a,c,b)
print(a,'-->',b)
hanoi(n-1,b,a,c)
n = int(input('enter n= '))
a = (input('enter a= '))
b = (input('enter b= '))
c = (input('enter c= '))
print(hanoi(n,a,b,c))