What are Python's string methods?
Why Interviewers Ask This
This is a classic screening question for Python roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
Python strings have a rich set of methods (all return new strings — strings are immutable). Case: upper(), lower(), title(), capitalize(), swapcase(). Strip: strip(), lstrip(), rstrip(). Find: find(sub) (returns -1 if not found), index(sub) (raises ValueError), count(sub), startswith(prefix), endswith(suffix). Replace: replace(old, new, count). Split/Join: split(sep), rsplit(sep, maxsplit), splitlines(), join(iterable). Check: isalpha(), isdigit(), isalnum(), isspace(), islower(), isupper(). Pad: center(width), ljust(width), rjust(width), zfill(width). Encode: encode("utf-8").
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Python project.