Array of 2^n

Artie Gold agold at
Sun Oct 21 05:17:25 CEST 2001

Moshe wrote:
> Okay, python newbie here. I'm liking what I see, but it seems like there
> are holes in the features of python's objects. I remember programming in
> squeak (an extension of smalltalk), and you could do complex operations on
> lists, and it would apply the result to each item. I want to make a n-item
> list such that mylist[i] = 2**i. How can I generate such a list in Python?
As an example, suppose you wanted the first 10 powers of 2 (i.e. 2**0 to

map(lambda x: 2**x, range(0,10)) 

would do it. Ayn b'ah'yah.

Artie Gold, Austin, TX  (finger the account for more info)
mailto:agold at or mailto:agold at
"Verbing weirds language." -- Calvin

More information about the Python-list mailing list