关于sum位置
请问为什么sum不能放在函数定义里面?
def square_of_sum(L): for x in L: sum=0 i=x*x sum=sum+i return sum print square_of_sum([1, 2, 3, 4, 5]) print square_of_sum([-5, 0, 5, 15, 25])
请问为什么sum不能放在函数定义里面?
def square_of_sum(L): for x in L: sum=0 i=x*x sum=sum+i return sum print square_of_sum([1, 2, 3, 4, 5]) print square_of_sum([-5, 0, 5, 15, 25])
2017-05-25
举报