xxxxxxxxxx
a = " yo! "
b = a.strip() # this will remove the white spaces that are leading and trailing
xxxxxxxxxx
text = " Example text with whitespace "
# Removing leading and trailing whitespace
trimmed_text = text.strip()
print(trimmed_text)
xxxxxxxxxx
Use the lstrip() method
>>> name = ' Steve '
>>> name
' Steve '
>>> name = name.lstrip()
>>> name
'Steve '