Python String Methods Cheatsheet

Interested in Pythonπ C++π€ UI/UX πΈ Web Developmentβ¨
What are strings?
β¨ In computer science, sequences of characters are called strings.
β¨ They can be of any length.
β¨ They can include any character such as letters, numbers, symbols or whitespace(spaces, tabs, new lines).
Below is a list of Python string methods ;)
String Methods
π capitalize(): Converts first character to uppercase.
π casefold(): converts string into lowercase.
π center(): returns a centered string.
π count(): returns the number of times a specified value occured in a string.
π encode(): returns an encoded string
π endswith(): returns true if string ended with the specified value.
π expandtabs(): sets tab size of the string.
π find() and index(): searches string for a specified value and returns the position of where the value was found.
π isascii(): returns true if all characters of a string are ascii characters.
π isdecimal(): returns true of all characters of a string are decimals.
π isdigit(): returns true if all characters in a string are digits.
π format() and format_map(): format specified value in a string.
π isalnum(): Returns true if all characters of a string are alphanumeric.
π isalpha(): Returns true if all characters of a string are in the alphabet.
π isnumeric(): returns true if all characters in a string are numeric.
π isprintable(): returns true if all characters in a string are printable.
π islower(): returns true if all characters of string are lower case.
π isupper(): returns true if all characters of string are upper case.
π join(): joins the elements of an iterable to end of a string.
π lower(): converts string in lower case.
π upper(): converts string in upper case.
πpartition(): return a tuple where string is parted in 3 portions.
π split(): splits the string at the specified separated and the returns a list.
π splitlines(): split string at line breaks and then returns a list.
π strip(): returns a trimmed version of a string.
π swapcase(): swaps cases, upper case becomes lower case and vice versa.
π title(): converts the first character of each word of a string to upper case.
π zfill(): fills string with specified number of 0 values at the beginning
π replace(): returns a string where the specified value is replaced with a specified value.
π isidentifier(): returns true if a string is an identifier.
Let's connect!
β¨ Twitter
β¨ Github






