I have a list of lists. I want to remove the leading and trailing spaces from them. The strip() method returns a copy of the string without leading and trailing
strip()
This generates a new list:
>>> x = ['a', 'b ', ' c '] >>> map(str.strip, x) ['a', 'b', 'c'] >>>
Edit: No need to import string when you use the built-in type (str) instead.
string
str