Or how about

sage: x = [1, 2, 3]
sage: y = [4, 5, 6]

sage: z = [a^b for (a, b) in zip(y, x)]

?

On Tue, Jul 21, 2009 at 4:52 PM, David Joyner <[email protected]> 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?
>
>
> > I attempted to turn my lists into arrays with no luck, and tried
> > creating a loop for the function but ended up with a bunch of numbers
> > labeled as "Integer Rings". Any help is appreciated.
> >
> > >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to