try this
a=[1, 2, 3]
b=a[:]
Daniel Mark [EMAIL PROTECTED] ???
news:[EMAIL PROTECTED] ???...
Hello all:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
Thank you
-Daniel
--
Daniel Mark [EMAIL PROTECTED] writes:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
BBB = [x-1 for x in AAA]
--
http://mail.python.org/mailman/listinfo/python-list
Tim Chase wrote:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
Sounds like a list comprehension to me:
Also the built in function 'map' would work:
a = [1,2,3]
b = map(lambda x: x-1, a)
b
[0, 1, 2]
List
Ant wrote:
Tim Chase wrote:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
Sounds like a list comprehension to me:
Also the built in function 'map' would work:
a = [1,2,3]
b = map(lambda x: x-1, a)
b
[0, 1, 2]
On 18 Sep 2006 15:43:31 -0700, Daniel Mark [EMAIL PROTECTED] wrote:
Hello all:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
You've had some excellent suggestions as to how to go about this
assuming that by efficient you mean in terms of CPU.
Hello all:
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
Thank you
-Daniel
--
http://mail.python.org/mailman/listinfo/python-list
I have a list AAA = [1, 2, 3] and would like to subtract one from list
AAA
so AAA' = [0, 1, 2]
What should I do?
Sounds like a list comprehension to me:
a = [1,2,3]
a_prime = [x-1 for x in a]
a_prime
[0, 1, 2]
-tkc
--
http://mail.python.org/mailman/listinfo/python-list