[SciPy-User] [SciPy-user] How to get access to Array elements
Rajeev Singh
rajs2010 at gmail.com
Sat May 7 06:14:29 EDT 2011
On Thu, May 5, 2011 at 8:20 PM, suzana8447 <k-assem84 at hotmail.com> wrote:
>
> Hello for all,
>
> I am still a beginner in the Python language.
> I have a problem and hope that some can help me.
> I my program I have an array called for example densities=
> 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.
> Thanks in advance.
>
> --
> View this message in context:
> http://old.nabble.com/How-to-get-access-to-Array-elements-tp31551042p31551042.html
> Sent from the Scipy-User mailing list archive at Nabble.com.
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
Hi,
Try -
densities = array([1,2,8,10,50)]
for i in range(5):
if densities[i] == 8:
print densities[i]
Hope it helps.
Rajeev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110507/a0b5cdf4/attachment.html>
More information about the SciPy-User
mailing list