generating range of numbers
Michael Bentley
michael at jedimindworks.com
Wed Oct 3 05:49:53 EDT 2007
On Oct 3, 2007, at 2:18 AM, vimal wrote:
> i am new to python.....
> i just want to generate numbers in the form like:
>
> 1,2,4,8,16,32.....to a maximum of 1024
>
> using a range function
I don't think it can be done with *only* a range function...
import math
[pow(2, x) for x in range(math.log(1024, 2) +1)]
hth,
Michael
---
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it. --Brian W. Kernighan
More information about the Python-list
mailing list