index存在的意义在哪里?
# coding=utf-8
I = []
for i in range(11):
I.append(i)
def sub_sum(I):
S=0
N=0
for L in I:
if (L%2)==0:
S=S+L
else:
N=N+L
return S,N
S,N=sub_sum(I)
print ('偶数和为:{}'.format(S))
print ('奇数和为:{}'.format(N))
##我这样写不是也对吗,答案中的index有啥意义呢
# coding=utf-8
I = []
for i in range(11):
I.append(i)
def sub_sum(I):
S=0
N=0
for L in I:
if (L%2)==0:
S=S+L
else:
N=N+L
return S,N
S,N=sub_sum(I)
print ('偶数和为:{}'.format(S))
print ('奇数和为:{}'.format(N))
##我这样写不是也对吗,答案中的index有啥意义呢
2022-05-08
举报