def test(a,b,invol):
if a==invol:
return 'ture'
else:
if a>invol:
invol=invol*b
test(a,b,invol)
else:
if a<invol:
return 'false'
print(test(9,3,1))
我是想要判断啊是否是b的乘方,从这个例子希望他输出为‘ture‘,’’然而其输出竟然是none
原因是在第二个if代码段中,没有return ,导致无返回值
所以需要在递归调用那里加上return就可以了