Errors while using strip and remove on a variable.
gherron at islandtraining.com
Thu Feb 3 10:29:13 EST 2011
On 02/03/2011 07:21 AM, anand jeyahar wrote:
> I am trying to strip a string and then remove on the resulting
> list to remove a set of characters. It works fine with the python shell.
> But after remove the list becomes None, when i am running it from
> within a script.
> I am guessing it has something to do with the way python handles
> please find the script below*
> a ='oe,eune,eueo, ,u'
> b = a.split(',')
> print b
> c = b.remove('oe')
> print a
> print c
On a list, the "remove" method does not create and return a new list --
instead it removes the element from the list in place. In your code,
you "print a" and "print c", but you should have done "print b", where
you will find the result you expect.
> Anand Jeyahar
> The man who is really serious,
> with the urge to find out what truth is,
> has no style at all. He lives only in what is.
> ~Bruce Lee
> Love is a trade with lousy accounting policies.
> ~Aang Jie
More information about the Python-list