| Name | .strip() | ||
|---|---|---|---|
| Examples | 
a = '              ...here...             '
# If no arguments are given strip() removes leading and trailing whitespace.
a = a.strip()
print(a)             # Prints '...here...'
aNoDots = a.strip('.') # Removes leading and trailing instances of '.'.
print(aNoDots)       # Prints 'here'
 | ||
| Description | Retruns a copy of the string with leading and trailing characters removed -- whitespace by default. Given an optional argument, strip removes specific leading and trailing characters. | ||
| Syntax | a.strip() a.strip(chars) | ||
| Parameters | 
 | ||
| Related | string String Formatting .find() .join() .split() .replace() | 
Updated on Tue Feb 27 14:07:12 2024.
If you see any errors or have comments, please let us know.
 
                    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License