stripping (from item in list)

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

On Sun, Jul 20, 2014 at 7:40 PM, Martin S <shieldfire at> 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.


More information about the Python-list mailing list