Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74880 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2014-07-20 13:15 -0400 |
| Last post | 2014-07-20 13:15 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: stripping (from item in list) Terry Reedy <tjreedy@udel.edu> - 2014-07-20 13:15 -0400
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-07-20 13:15 -0400 |
| Subject | Re: stripping (from item in list) |
| Message-ID | <mailman.12097.1405876575.18130.python-list@python.org> |
On 7/20/2014 5:40 AM, Martin S wrote:
> while c >=0:
> x=games[c][0]
> if x=="#":
> del games[c] #This removes the comments from the file parsed
> else:
> games[c].rstrip('\n') #This does nothing, expected to remove \n
Chris already pointed out error here.
> c=c-1
> # Now we have a list with only proper lines
I believe what you are aiming for is
games = [line.rstrip('\n') for line in games if line[0] != '#']
--
Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web