never thought about using zip. seems like python is more compact in it's programing then mathematica.
On Jan 2, 9:41 am, Nils Bruin <[email protected]> wrote: > On Jan 2, 9:24 am, Eric Kangas <[email protected]> wrote:> for x in > l1,l2: > > if l1[x:x+1]==l2[x:x+1]; > > That semicolon gives you the syntax error, but correcting that only > exposes a runtime error. You should look at what your x is in the > loop. > > If you write "for x in range(len(l1))" you are a little closer > already. > > Most of the time, filtering jobs like this can be accomplished by one- > liners using the right list combination and iteration tools: > > [c for c in enumerate(zip(l1,l2)) if c[1][0] ==c[1][1]] -- 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
