On Friday, March 30, 2012 9:41:14 AM UTC-7, Eric Kangas wrote:
>
> Hi,
>
> I am trying to find the values, and locations of those values in a 
> sequence of numbers. I have written up code that I thought would work, but 
> it doesn't. Here is the code:
>
> l31 = [len(l3[i]) for i in range(a/len(l))];
>
> l32 = [];
>
> l33 = [if x=6: l32.append((x,l31[x])) for x in l31];
>

You could do this:

   sage: [l32.append((x, l31[x])) for x in l31 if x == 6]

(The "if" part comes at the end, and instead of "x=6" you need "x==6".)

This will return a list all of whose entries are None (because 
l32.append(...) returns None each time it is evaluated), and it will also 
modify l32.  Maybe instead you should probably do

  sage: [(x,l31[x]) for x in l31 if x == 6]

-- 
John

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to