On Jul 21, 2009, at 4:52 PM, David Joyner wrote: > > On Tue, Jul 21, 2009 at 6:56 PM, Mike<[email protected]> wrote: >> >> Hi, I have a quick question. I'm fairly new to python and sage, >> and am >> attempting to learn it to use in my engineering classes. My >> problem is >> that I have 2 lists >> x = [1, 2, 3] >> y = [4, 5, 6] >> and I would like to use them both in the same function to give me a >> third list. Something to the effect of: >> z = [4^1, 5^2, 6^3] = [4, 25, 216] > > > Is > > sage: x = [1, 2, 3] > sage: y = [4, 5, 6] > sage: z = [y[i]^x[i] for i in range(3)]; z > [4, 25, 216] > > > what you want?
Or even sage: [a^b for a,b in zip(y,x)] [4, 25, 216] - Robert --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sage-edu" group. 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-edu?hl=en -~----------~----~----~----~------~----~------~--~---
