i=2; lst=[i**=2 while i<1000]
D H
x at y.z
Tue Dec 6 09:17:06 EST 2005
Daniel Schüle wrote:
> Hello NG,
>
> I am wondering if there were proposals or previous disscussions in this
> NG considering using 'while' in comprehension lists
>
> # pseudo code
> i=2
> lst=[i**=2 while i<1000]
>
> of course this could be easily rewritten into
> i=2
> lst=[]
> while i<1000:
> i**=2
> lst.append(i)
That would loop endlessly since you don't increment i.
You can use i**=2 for i in range(1000) instead
More information about the Python-list
mailing list