I am trying to delete empty elements of a list named report info split but keep getting list out of range errors.
The list looks similar to this :
reportinfosplit = [[1,,g,5,44,f][1,5,4,f,g,,g]]
I have found many answers to this for 1d arrays but not 2d. Is there a way to prevent the index from going out of range? The list elements are not all the same size, and I thought that was the reason, but it kept happening after I made them the same length.
for i in range(len(reportinfosplit)):
for j in range(len(reportinfosplit[i])):
if(j<=len(reportinfosplit[i])):
if reportinfosplit[i][j] == "":
del reportinfosplit[i][j]
if(j<=len(reportinfosplit[i]))->if(j<len(reportinfosplit[i]))might do the trick