Re: how to append to list in list comprehension

2016-10-01 Thread Sayth Renshaw
On Saturday, 1 October 2016 14:17:06 UTC+10, Rustom Mody wrote: > On Saturday, October 1, 2016 at 9:08:09 AM UTC+5:30, Sayth Renshaw wrote: > > I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if > > there are better non list comprehension options I would like to know as > >

Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
On Saturday, 1 October 2016 14:17:06 UTC+10, Rustom Mody wrote: > On Saturday, October 1, 2016 at 9:08:09 AM UTC+5:30, Sayth Renshaw wrote: > > I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if > > there are better non list comprehension options I would like to know as > >

Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 9:08:09 AM UTC+5:30, Sayth Renshaw wrote: > I do like [(f + ['0'] if len(f) < 5 else f) for f in fups ] Rustom, if there > are better non list comprehension options I would like to know as generally I > find then confusing. Two points here — best taken

Re: how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
> > I want to go threw and for each index error at [4] append a 0. > > You want to append 0 if the list does not have at least 5 items? > > > p = re.compile('\d+') > > fups = p.findall(nomattr['firstup']) > > [x[4] for x in fups if IndexError fups.append(0)] > > print(fups) > > > Unsure why I

Re: how to append to list in list comprehension

2016-09-30 Thread Rustom Mody
On Saturday, October 1, 2016 at 7:48:19 AM UTC+5:30, John Gordon wrote: > In Sayth Renshaw writes: > > > I want to go threw and for each index error at [4] append a 0. > > You want to append 0 if the list does not have at least 5 items? > > > p = re.compile('\d+') > > fups =

Re: how to append to list in list comprehension

2016-09-30 Thread John Gordon
In <534d5506-1810-4a79-ac8f-95a664d17...@googlegroups.com> Sayth Renshaw writes: > I want to go threw and for each index error at [4] append a 0. You want to append 0 if the list does not have at least 5 items? > p = re.compile('\d+') > fups =

how to append to list in list comprehension

2016-09-30 Thread Sayth Renshaw
I have a list of lists of numbers like this excerpt. ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['0', '0', '0', '0'] ['7', '2', '1', '0', '142647', '00'] ['7', '2', '0', '1', '87080', '00'] ['6', '1', '1', '1', '51700', '00'] ['4',