I need to implement Sieve of Eratosthenes algorithm.
I have list:
bar = [2, 3, 4, 5, 6, 7, 8, 9, 10]
I need to replace each odd element with "0".
Now I have code:
while viewIndex < maxNumber:
bar[viewIndex] = 0
viewIndex += 2
But I remember about slices. And for me it will be nice to write something like this:
bar[currentIndex::2] = 0
But I have error:
TypeError: must assign iterable to extended slice
Maybe you know a beautiful solution to this task.