List Manipulation
Iain King
iainking at gmail.com
Tue Jul 4 10:17:28 EDT 2006
Roman wrote:
> I would appreciate it if somebody could tell me where I went wrong in
> the following snipet:
>
> When I run I get no result
>
> cnt = 0
> p=[]
> reader = csv.reader(file("f:\webserver\inp.txt"), dialect="excel",
> quotechar="'", delimiter='\t')
> for line in reader:
> if cnt > 6:
> break
> for col in line:
> p[:0].append(str(col))
What are you trying to do here? p[:0] returns a new list, of all the
elements in p up to element 0 (which is of course the empty list),
which is then appended to, but is not stored anywhere. If you want to
insert str(col) then use p.insert
Iain
More information about the Python-list
mailing list