谁能告诉我这个index是干吗用的?
def sub_sum(L): index = 0 sum1 = 0 sum2 = 0 for item in L: if index % 2 == 0: sum1 += item else: sum2 += item index += 1 return sum1, sum2 L = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] result = sub_sum(L) print('奇数项的和 = {}'.format(result[0])) print('偶数项的和 = {}'.format(result[1]))