[Tutor] Please Help
Andreas Perstinger
andipersti at gmail.com
Fri Mar 22 14:14:43 CET 2013
Please use a meaningful subject.
On 22.03.2013 13:37, Arijit Ukil wrote:
> I have the following data points.
> data = [1,2,0,9,0,1,4]
> I like to store in an array and print the odd-indexed points, i.e. 2, 9,1
> (considering index starts at 0)
You can simply slice your list:
>>> data = [1, 2, 0, 9, 0, 1, 4]
>>> number_list = data[1::2]
>>> number_list
[2, 9, 1]
See also
http://docs.python.org/3/library/stdtypes.html#common-sequence-operations
Bye, Andreas
More information about the Tutor
mailing list