'Why is there a difference in the results of both the for loops?
Both of the for loops are the exact same but i dont understand why the first for loop isnt working.
t = [[1,0],[2,0]]
z = [[1,0],[2,0]]
for i in t:
i = [x for x in i if x!=0]
for i in range(len(z)):
z[i] = [x for x in z[i] if x!=0]
print(t)
print(z)
Output:
[[1, 0], [2, 0]]
[[1], [2]]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
