Answers for "python strim trim"

1

python strim trim

string ='   abc   '

# After removing leading whitespace
print(string.lstrip());
# Output: 'abc   '

# After removing trailing whitespace
print(string.rstrip());
# Output: '   abc'

# After removing all whitespace
print(string.strip());
# Output: 'abc'
Posted by: Guest on March-18-2020

Python Answers by Framework

Browse Popular Code Answers by Language