-1

I have this list [1268857, 384269, 72468, 161, 0, 0, 0, 0, 0, 0, 0], in which I compute a log calculation on each value. So I first remove the zeros and then I get this list: [14.05362705319161, 12.859098107153008, 11.190900364095901, 5.0814043649844631] . But the problem is that the last list will repeat itself 7 times. Is there a way to stop it from generating itself over and over?

I've tried this:

for item in gy:
    if item == 0:
        gy.remove(item)
    if item < 0:
        gy.remove(item)
    if item == (item - 1):
        gy.remove(item)

Although it removes the next item that repeats himself, gives me also an error:

 ValueError: list.remove(x): x not in list

Is there a better way to do this?

Mazdak
  • 105,000
  • 18
  • 159
  • 188
dbpyth
  • 61
  • 6

1 Answers1

0

Do something like this

gy = list(set(gy))
gy.remove(gy.index(0))
user2097159
  • 862
  • 5
  • 13