problem about list indexing
Steven D'Aprano
steve at REMOVE.THIS.cybersource.com.au
Sun Nov 26 05:35:39 EST 2006
On Sun, 26 Nov 2006 00:25:13 -0800, hollowspook wrote:
> Hi, there
>
> a = range(100)
>
> if I want to use No 7, 11, 56,90 in a, then the only way I do is [a[7],
> a[11], a[56], a[90]].
> Is there any other way?
a = [7, 11, 56, 90]
Are those numbers supposed to be in some sort of series? They aren't an
arithmetic series:
(11 - 7) = 4
(56 - 11) = 45 # not a constant difference
nor are they a geometric series:
(11/7) = 1.57
(56/11) = 5.09 # not a constant ratio
They don't look like some form of a Fibonacci series:
7+11 != 56
11+56 != 90
If they're just "random" numbers, plucked out of thin air, then you
probably can't calculate them and you'll need to just create them in a
list a = [7, 11, 56, 90].
--
Steven.
More information about the Python-list
mailing list