stripping (from item in list)

Martin S shieldfire at gmail.com
Sun Jul 20 06:06:03 EDT 2014


Craps should have guessed that was the problem. Must have
misunderstood the examples.

But thanks =)

And yes, definately should be able to build a better parser ... I want
it to work first.

/Martin S

2014-07-20 11:57 GMT+02:00 Chris Angelico <rosuav at gmail.com>:
> 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
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Regards,

Martin S



More information about the Python-list mailing list