[SciPy-User] [SciPy-user] How to get access to Array elements

Keith Goodman kwgoodman at gmail.com
Fri May 6 09:45:41 EDT 2011


On Thu, May 5, 2011 at 7:50 AM, suzana8447 <k-assem84 at hotmail.com> wrote:

> array([1,2,8,10,50)]
> note that the third element in the array is 8.  I want to form an if
> statement as this:
> if(x==8): print x # just as an example.
> But how to declare x as the third elemnt of the above array.

Here's an example:

    >> import numpy as np
    >> a = np.array([1,2,8,10,50])
    >> a[0]
       1
    >> a[1]
       2
    >> a[2]
       8
    >> a[3]
       10
    >> a[4]
       50



More information about the SciPy-User mailing list