How to store the contents of a file into a list?
Daniel
Daniel.Kinnaer at AdValvas.be
Sat Jan 6 14:32:19 EST 2001
Hi guys. As a newbie exercise, I've been trying the following :
l1 = []
l2 = ['rec11','rec12','rec13']
l3 = ['rec21','rec22','rec23']
l1.append(l2)
l1.append(l3)
l1 now is [['rec11', 'rec12', 'rec13'], ['rec21', 'rec22', 'rec23']]
I've been trying to do the same when reading these records from a file
(The file contains 2 lines :
rec11,rec12,rec13
rec21,rec22,rec23)
What needs to be done to obtain the same l1 as above? I've been trying
various ways but my l1 always reads ['rec11, rec12, rec13', 'rec21,
rec22, rec23'] instead of [['rec11', 'rec12', 'rec13'], ['rec21',
'rec22', 'rec23']]. What am I doing wrong? All help greatly
appreciated.
Thanks
Daniel
More information about the Python-list
mailing list