Python String Methods Overview

Python string methods most commonly used str.lower() - converts to lowercase str.upper() - converts to uppercase str.capitalize() - capitalizes first letter str.title() - capitalizes first letter of each word str.find(sub) - returns lowest index or -1 str.index(sub) - like find but raises ValueError str.count(sub) - counts occurrences str.replace(old, new) - replaces occurrences str.strip() - removes leading/trailing whitespace str.split(sep) - splits into list sep.join(iterable) - joins iterable with separator str.format(*args, **kwargs) - formats string

To view or add a comment, sign in

Explore content categories