N=input('N:')
i=1
s=1
X=int(N)
def sum(X):
while 1:
s=s*X
X-=1
if not X:
break
return s
SUM=sum(5)
print SUM
这里哪里错了???
错误报告:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/test.py", line 18, in <module>
SUM=sum(5)
File "C:/Users/Administrator/Desktop/test.py", line 12, in sum
s=s+X
UnboundLocalError: local variable 's' referenced before assignment
慕容森
jeck猫
相关分类