0
我在Python写了这个代码3.5有人可以重新编写代码没有任何错误
temp=0
def add1(x):
f=12
if temp < x:
for i in range(20):
temp=temp + f
print(temp)
add1(21)
Traceback (most recent call last): File "<pyshell#29>", line 1, in
<module>
add1(12) File "<pyshell#28>", line 3, in add1
if temp < x: UnboundLocalError: local variable 'temp' referenced before assignment