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