Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> ' Hello '.strip()
- 'Hello'
- >>> ' Hello'.strip()
- 'Hello'
- >>> 'Bob has a cat'.strip()
- 'Bob has a cat'
- >>> ' Hello '.strip() # ALL spaces at ends removed
- 'Hello'
- def strip_one_space(s):
- if s.endswith(" "): s = s[:-1]
- if s.startswith(" "): s = s[1:]
- return s
- >>> strip_one_space(" Hello ")
- ' Hello'
- >>> " Hellon".strip(" ")
- 'Hellon'
- myString.strip()
- myString.strip()
- myphrases = [ " Hello ", " Hello", "Hello ", "Bob has a cat" ]
- for phrase in myphrases:
- print phrase.strip()
Add Comment
Please, Sign In to add comment