remove leading spaces python code example
Example 1: remove trailing and leading spaces in python
text = " Hello World "
text.strip()
# Hello World
Example 2: python remove whitespace from start of string
' hello world! '.strip()
'hello world!'
' hello world! '.lstrip()
'hello world! '
' hello world! '.rstrip()
' hello world!'