Let's say I've defined list of lists, e.g.:
a = [[1,2,1,1,1],[1,1,3,4,1],[2,1,2,5,1],[1,1,2,2,3],[1,1,1,1,1]]
What I want to do is to create a loop which will be iterating through every list in list a
and replace elements in given range (increasing by 1 when moving to next list) with zeros, so the output will be:
a = [[1,2,1,1,1],[0,1,3,4,1],[0,0,2,5,1],[0,0,0,2,3],[0,0,0,0,1]]
I've tried different ideas, but finally none of them seem to be working and I feel like I'm misunderstanding something.
I've tried:
k = 0
for i in range(len(a)):
a[i][:k] = 0
k += 1
But it didn't work.