@FrankZhang6/

teachalex

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def sumList(x):
  p = 0
  for index in range(len(x)):
    if index % 2 == 0:
      p += x[index]
  return p


a = [1, 5, 7, 14, 9]
b = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
c = [8, 5, 0, 3, 6, 1, 7]

lib = [a, b, c] #2D list (list containing lists)

for index in range(len(lib)):
  print(sumList(lib[index]))