Here is a table of commonly used built-in string methods in Python:
Method | Description |
str.upper() | Returns a new string in all uppercase letters |
str.lower() | Returns a new string in all lowercase letters |
str.capitalize() | Returns a new string with the first letter capitalized |
str.title() | Returns a new string with the first letter of each word capitalized |
str.strip() | Returns a new string with leading and trailing whitespace removed |
str.replace(old, new) | Returns a new string with all occurrences of a substring replaced with another substring |
str.startswith(substring) | Returns True if the string starts with the specified substring |
str.endswith(substring) | Returns True if the string ends with the specified substring |
str.split() | Returns a list of substrings separated by whitespace |
str.split(separator) | Returns a list of substrings separated by the specified separator |
str.join(iterable) | Returns a new string by concatenating the elements of an iterable with the string as a separator |
str.find(substring) | Returns the lowest index where the substring is found, or -1 if it is not found |
str.index(substring) | Returns the lowest index where the substring is found, or raises a ValueError if it is not found |
str.count(substring) | Returns the number of times the substring appears in the string |
str.isalpha() | Returns True if all characters in the string are alphabetic |
str.isnumeric() | Returns True if all characters in the string are numeric |
str.isalnum() | Returns True if all characters in the string are alphanumeric |
str.isdigit() | Returns True if all characters in the string are digits |
str.islower() | Returns True if all characters in the string are lowercase |
str.isupper() | Returns True if all characters in the string are uppercase |
These are just some of the commonly used string methods in Python. The full list of string methods can be found in the Python documentation.
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.