Question: ```
>>> a=range(5)
>>> [a[i] for i in range(0,len(a),2)] ## list comprehension for side effects
[0, 2, 4]
>>> a
[0, 1, 2, 3, 4]
>>> [a[i]=3 for i in range(0,len(a),2)] ## try to do assignment
SyntaxError: invalid syntax
>>> def setitem(listtochange,n,value):  ## function to overcome limitation
    listtochange[n]=value
    return value

>>> [setitem(a,i,'x') for i in range(0,len(a),2)] ## proving the function
['x', 'x', 'x']
>>> a 
['x', 1, 'x', 3, 'x']   # We did assignment anyway

```

Answer: 
Yes. And I recommend using

```
a[::2] = ['x'] * len(a[::2])

```

instead.

---

Edit:

Microbenchmarks for Python 2.6:

```
~:249$ python2.6 -m timeit -s 'a = range(2000)' 'a[::2] = [8] * len(a[::2])'
10000 loops, best of 3: 26.2 usec per loop

~:250$ python2.6 -m timeit -s 'a = range(2000)' 'a[::2] = [8] * (len(a)/2)'
10000 loops, best of 3: 19.6 usec per loop

~:251$ python2.6 -m timeit -s 'a = range(2000)' 'for i in xrange(0,len(a),2): a[i] = 8'
10000 loops, best of 3: 92.1 usec per loop

~:252$ python2.6 -m timeit -s 'a = range(2000)
> def assign(x,i,v):x[i]=v;return v' '[assign(a,i,8) for i in xrange(0, len(a), 2)]'
1000 loops, best of 3: 336 usec per loop

```

Python 3.1:

```
~:253$ python3.1 -m timeit -s 'a = list(range(2000))' 'a[::2] = [8] * len(a[::2])'
100000 loops, best of 3: 19.8 usec per loop

~:254$ python3.1 -m timeit -s 'a = list(range(2000))' 'a[::2] = [8] * (len(a)//2)'
100000 loops, best of 3: 13.4 usec per loop

~:255$ python3.1 -m timeit -s 'a = list(range(2000))' 'for i in range(0,len(a),2): a[i] = 8'
10000 loops, best of 3: 119 usec per loop

~:256$ python3.1 -m timeit -s 'a = list(range(2000))
> def assign(x,i,v):x[i]=v;return v' '[assign(a,i,8) for i in range(0, len(a), 2)]'
1000 loops, best of 3: 361 usec per loop

```
You can also use `list.__setitem__`

```
a = range(5)
[a.__setitem__(i,"x") for i in range(0,len(a),2)]

```

Or if you want to avoid the contruction of an intermediate list:

```
any(a.__setitem__(i,"x") for i in range(0,len(a),2))

```

But assignment in list comprehensions is indeed unpythonic.