Saturday, November 3, 2018

Python. How to remove zeroes from a list in Python

X = [0,5,0,0,3,1,15,0,12]

for value in range(0,len(X)):

if X[value] <= 0:

del X[value]
print(X)
print(X)


I run the code but then i get an error saying that the list is out of index range.
Can someone please help me out on how to correct this mistake

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...