I already asked a similar question, but encounter problems with
python...
How can I concatenate the elements in each list of a list of lists
list_of_listsA =
[['klas*', '*', '*'],
['mooi*', '*', '*', '*'],
['arm*', '*', '*(haar)']]
wanted result:
list_of_listsA =
[['klas* * *']
['mooi* * * *']
['arm* * *(haar)']]
Thanks a lot ! 3 2651
On Jul 23, 5:33*pm, antar2 <desoth...@yahoo.comwrote:
I already asked a similar question, but encounter problems with
python...
How can I concatenate the elements in each list of a list of lists
list_of_listsA =
[['klas*', '*', '*'],
['mooi*', '*', '*', '*'],
['arm*', '*', '*(haar)']]
wanted result:
list_of_listsA =
[['klas* * *']
['mooi* * * *']
['arm* * *(haar)']]
Thanks a lot !
Nice and easy. :)
>>list_of_listsA = [['klas*', '*', '*'],
['mooi*', '*', '*', '*'],
['arm*', '*', '*(haar)']]
>>[' '.join(l) for l in list_of_listsA]
['klas* * *', 'mooi* * * *', 'arm* * *(haar)']
Am Wed, 23 Jul 2008 08:33:57 -0700 wrote antar2:
I already asked a similar question, but encounter problems with
python...
How can I concatenate the elements in each list of a list of lists
list_of_listsA =
[['klas*', '*', '*'],
['mooi*', '*', '*', '*'],
['arm*', '*', '*(haar)']]
wanted result:
list_of_listsA =
[['klas* * *']
['mooi* * * *']
['arm* * *(haar)']]
Thanks a lot !
Hello,
maybe this will help:
In [5]: list_of_listsA = [['klas*', '*', '*'], ['mooi*', '*', '*', '*'],
['arm*', '* ', '*(haar)']]
In [6]: s = ""
In [7]: print [[s.join(item)] for item in list_of_listsA]
[['klas***'], ['mooi****'], ['arm** *(haar)']]
regards
Michael
On 23 Juli, 17:33, antar2 <desoth...@yahoo.comwrote:
I already asked a similar question, but encounter problems with
python...
How can I concatenate the elements in each list of a list of lists
list_of_listsA =
[['klas*', '*', '*'],
['mooi*', '*', '*', '*'],
['arm*', '*', '*(haar)']]
wanted result:
list_of_listsA =
[['klas* * *']
['mooi* * * *']
['arm* * *(haar)']]
Thanks a lot !
wanted_result = [[item] for item in map(' '.join, list_of_listsA)] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matthew Sims |
last post by:
Python Newbie here. This is my first time learning object-oriented
programming and trying to break out of the usual Korn/Perl/PHP style
of programming. Having some difficulty understand some items....
|
by: Steven Bethard |
last post by:
I think one of the biggest reasons we're having such problems coming
to any agreement on decorator syntax is that each proposal makes a
number of syntax decisions, not just one. For decorators, I...
|
by: Nickolay Kolev |
last post by:
Hi all,
I have a list whose length is a multiple of 3. I want to get a list of
tuples each of which has 3 consecutive elements from the original list,
thus packing the list into smaller...
|
by: Nick Heppleston |
last post by:
I have a concatenation problem and I was wondering if somebody might be
able to offer some help :-)
I have the following table structure holding product long descriptions:
Part...
|
by: Generic Usenet Account |
last post by:
To settle the dispute regarding what happens when an "erase" method is
invoked on an STL container (i.e. whether the element is merely
removed from the container or whether it also gets deleted in...
|
by: Adam Hartshorne |
last post by:
Hi All,
I have the following problem, and I would be extremely grateful if
somebody would be kind enough to suggest an efficient solution to it.
I create an instance of a Class A, and...
|
by: Grzegorz ¦lusarek |
last post by:
Hi all. I my application i have situation when i have some lists and i
must get from lists common elements. Exacly i don't know how many list I
have so at the moment of creation each of one I...
|
by: Zytan |
last post by:
Obviously you can't just use a simple for loop, since you may skip
over elements.
You could modify the loop counter each time an element is deleted.
But, the loop ending condition must be...
|
by: antar2 |
last post by:
Hello,
I am a beginner in python.
following program prints the second element in list of lists 4 for the
first elements in list 4 that are common with the elements in list 5
list4 = ,,]...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
| |