concatenate the elements in each list of a list of lists

2008-07-23 Thread 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* * * *']

convert list of lists to list

2008-07-22 Thread antar2
Is there a way to convert list_of_listsA to list_of_listsB, where one list in listof lists A is one element of listB? list_of_listsA: [['klas*', '*', '*'], ['mooi*', '*', '*', '*'], ['koe'], ['arm*', '*', '*(haar)'], ['groei*', '*', '*', '*', '*']] listB: ['klas* * *', 'mooi* * * *, 'koe', 'arm*

substitution of list elements

2008-07-18 Thread antar2
I want to replace each first element in list 5 that is equal to the first element of the list of lists4 by the fourth element. I wrote following code that does not work: list4 = [['1', 'a', 'b', 'c'], ['2', 'd', 't', 'e'], ['8', 'g', 'q', 'f']] list5 = ['1', '2', '3'] for j in list4: for k in l

common elements between list of lists and lists

2008-07-17 Thread antar2
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 = [['1', 'a'],['4', 'd'],['8', 'g']] list5 = ['1', '2', '3'] for j in list4: for k in list5:

read file into list of lists

2008-07-11 Thread antar2
Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], that the word pear

start reading from certain line

2008-07-09 Thread antar2
I am a starter in python and would like to write a program that reads lines starting with a line that contains a certain word. For example the program starts reading the program when a line is encountered that contains 'item 1' The weather is nice Item 1 We will go to the seaside ... Only the li

delete lines

2008-07-09 Thread antar2
I am new in python and I have the following problem: Suppose I have a list with words of which I want to remove each time the words in the lines below item1 and above item2: item1 a b item2 c d item3 e f item4 g h item1 i j item2 k l item3 m n item4 o p I did not find out how to do this: Part o

list previous or following list elements

2008-06-26 Thread antar2
Hello Suppose I have a textfile (text1.txt) with following four words: Apple balcony cartridge damned paper bold typewriter and I want to have a python script that prints the words following the word starting with the letter b (which would be cartridge) or differently put, a script that prints

reading from list with paths

2008-06-25 Thread antar2
Antar2 -- http://mail.python.org/mailman/listinfo/python-list

reading from list with paths

2008-06-25 Thread antar2
directory, but after trying to find this out my self, I give up... So could someone help me and write some code so that I know how to open and read the content of the mentioned files. Thanks a lot Antar2 -- http://mail.python.org/mailman/listinfo/python-list

python -regular expression - list element

2008-06-25 Thread antar2
Hello, I am a beginner in Python and am not able to use a list element for regular expression, substitutions. list1 = [ 'a', 'o' ] list2 = ['star', 'day', 'work', 'hello'] Suppose that I want to substitute the vowels from list2 that are in list1, into for example 'u'. In my substitution, I shou