[Tutor] Please Help

Asokan Pichai pasokan at talentsprint.com
Fri Mar 22 14:34:09 CET 2013


On Fri, Mar 22, 2013 at 6:07 PM, Arijit Ukil <arijit.ukil at tcs.com> 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)
>
> *I have written the following code which is** not **running:*
>
> import math
>
> number_list = [1,2,0,9,0,1,4]
>
> number_list_1 = []
> for k in range(math.floor(float(len(number_list)/2))):
>     if (k< math.floor(float(len(number_list)/2))):
>                     number_list_1[k] = number_list[k*2 + 1]
>
> print *'data: '*, number_list_1
>
> Please help
>
> Regards,
>


I would suggest that your roblems have more to do with insufficient
understanding of basic constructs, and
that you should work on them, "Learn Python the hard way" a book by Zed
Shaw is a good one.

Why do I say that? Among other things,

k< math.floor(float(len(number_list)/2))

is very poor in any language.

Asokan Pichai

The root of all superstition is that men observe when a thing hits, but not
when it misses. -- Francis Bacon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130322/626ef56c/attachment.html>


More information about the Tutor mailing list