a = [[' 0 ', '*X*', '*Y*', '*Z*'], [' 0 ', '*X*', '*Y*', '*Z*'], [' 0 ', '*X*', '*Y*', '*Z*']]
for i in a:
for j in i:
if '*' in j:
i.remove(j)
for i in range(len(a)):
for j in range(len(a[i])):
if '*' in a[i][j]:
del a[i][j]
I try to delete the item contain star in the list, but the first loop will give me out of range error, and the second loop will still have y does not delete, how do I fix the problem? Thank you very much