Sep-13-2019, 05:22 PM
Try not copy in line number in code.
So this is the start.
So this is the start.
>>> lst = main() >>> lst [[[2, 1, 4, 3], [3, 4, 2, 1]], [[1, 0, 0, 3], [0, 3, 1, 1]], [[0, 1, 4, 2], [4, 0, 1, 3]], [[1, 0, 0, 4], [3, 3, 0, 0]], [[3, 1, 3, 0], [3, 4, 4, 2]]]So to use eg
sum()
on the list need first to flatten the list out.>>> for i in lst: ... lst = [item for n in i for item in n] ... print(lst) ... [2, 1, 3, 4, 1, 4, 3, 4] [4, 0, 1, 3, 0, 3, 0, 0] [0, 0, 0, 1, 2, 1, 4, 0] [2, 1, 0, 1, 4, 1, 4, 3] [4, 0, 3, 4, 1, 4, 2, 2]Now will sum() work.
>>> lst = main() >>> for i in lst: ... lst = [item for n in i for item in n] ... print(sum(lst)) ... 17 18 13 12 15Then i think you can do the last step if want the total sum.