stripping (from item in list)

Chris Angelico rosuav at gmail.com
Sun Jul 20 11:57:30 CEST 2014


On Sun, Jul 20, 2014 at 7:40 PM, Martin S <shieldfire at gmail.com> wrote:
>             games[c].rstrip('\n') #This does nothing, expected to remove \n
>
> While all records in the remaining list now are valid, all also still
> have "\n" at the end. What did I miss here?

Strings don't change. When you call rstrip(), it returns a new string
which is the stripped value. You'll need to slot that back in:

games[c] = games[c].rstrip('\n')

However, there may be a better way to do this - possibly a cleaner parser.

ChrisA



More information about the Python-list mailing list