473,473 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A question about list

Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!

Oct 17 '06 #1
5 886

pr*************@hotmail.com wrote:
Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!
>>a = [[1,1], [2,2]]
map( lambda x: x + ['='], a )
[[1, 1, '='], [2, 2, '=']]
>>>
Oct 17 '06 #2
pr*************@hotmail.com wrote:
Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!
To copy a list use:

b=a[:]

-Larry
Oct 17 '06 #3
pr*************@hotmail.com wrote:
Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
b = [item + ['='] for item in a]

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Oct 17 '06 #4
pr*************@hotmail.com wrote in news:1161102973.920895.141500
@i42g2000cwa.googlegroups.com:
Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!
b = [[x,y,'='] for (x,y) in a]

--
rzed
Oct 17 '06 #5
Larry Bates wrote:
pr*************@hotmail.com wrote:
>Hello:
Variable 'a' has the next values:
[[1,1],[2,2]]
and I want to take a to b as:
[[1,1,'='],[2,2,'=']]
How can I do this with only one line of instruction?
Thanks!!
To copy a list use:

b=a[:]

-Larry
Seems I may have misunderstood the question, but others
have answered appropriately.

-Larry
Oct 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Marco Aschwanden | last post by:
Hi I don't have to talk about the beauty of Python and its clear and readable syntax... but there are a few things that striked me while learning Python. I have collected those thoughts. I am...
3
by: fdsl ysnh | last post by:
--- python-list-request@python.orgдµÀ: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, > visit >...
17
by: kj | last post by:
How can one test if a pointer has been "freed" (i.e. with free())? My naive assumption was that such a pointer would equal NULL, but not so. Thanks, kj -- NOTE: In my address everything...
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
2
by: pinkfog | last post by:
Hello,all I m just a newbie to c,and now i m learning quick sorting,i dont very undertand this algorrithm,can someone kind to explain it to me? the code: <quote> void quick_sort(int a ,int low...
3
by: neilcancer | last post by:
My English is poor... There are some sort algorithms which sort a sequencial list. The sequencial list was defined in "list-seq.h". sort_and_time() accepts one of these sort functions. It uses...
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
75
by: Steven T. Hatton | last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash, Mathematica, SML, or LISP. A college teacher recently posted to this newsgroup regarding her observation that there has...
10
by: Ruan | last post by:
My confusion comes from the following piece of code: memo = {1:1, 2:1} def fib_memo(n): global memo if not n in memo: memo = fib_memo(n-1) + fib_memo(n-2) return memo I used to think that...
1
by: BillG | last post by:
I am developing a business app using asp.net that will have 2 different types of forms, a list view of data and then a detail view. The list views are placed on a content panel in a master page. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.