String Methods Extended
Removing Leading and/or Trailing Spaces
# Strip() Examples
word1 = ' h ello '
# 3 spaces then h ello then 3 spaces
print('word1.lstrip():', word1.lstrip(), 'world.')
print('word1.rstrip():', word1.rstrip(), 'world.')
print('word1.strip():', word1.strip(), 'world.')word1.lstrip(): h ello world.
word1.rstrip(): h ello world.
word1.strip(): h ello world.Using replace()
replace()Using startswith() and endswith()
startswith() and endswith()Items in a Sequence to String
String to a List
Last updated