String Methods

MethodDescription
upper() / lower()Change case
strip() / lstrip() / rstrip()Trim whitespace
replace(old, new)Replace substring
split(sep)Split into a list
join(iterable)Join strings with separator
find(sub) / index(sub)Locate substring
startswith(prefix) / endswith(suffix)Prefix / suffix check
isdigit() / isalpha() / isalnum()Character tests
format(...)Format string
count(sub)Count occurrences
Example
s = "  Hello, Python  "
print(s.strip().lower().replace("python", "world"))