|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def mul(n):
if n == 1:
return 1
else:
n * mul(n-1)
print(mul(4))
运行结果入下:
Traceback (most recent call last):
File "F:\python学习文件夹\python practices\reverse.py", line 6, in <module>
print(mul(4))
File "F:\python学习文件夹\python practices\reverse.py", line 5, in mul
n * mul(n-1)
File "F:\python学习文件夹\python practices\reverse.py", line 5, in mul
n * mul(n-1)
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
>>>
为什么会出现错误,鄙人大概想到可能是返回值的问题,但因为基础不够牢固,所以有点想不明白,请大佬指教
|
|