Python String Methods

Last Updated:

Python String Methods

The following are the list of inbuilt string methods in Python programming.

MethodsExplanation
capitalize() Converts the first character of a string to capital (uppercase) letter.
casefold() Converts a string into lowercase.
center() Returns a string which is padded with the specified character.
count() Returns the number of times a given value occurs in a string.
encode() Returns an encoded version of the string.
endswith() Checks whether the specified string matches the end of the given string or not.
expandtabs() Return a copy of the string where all tab characters are expanded to the specified number of whitespaces.
find() Returns the index value of the first occurrence of the substring in the given string within the specified limit.
format() Formats strings contain "replacement fields" surrounded by curly braces {}.
format_map() Returns a dictionary key's value.
index() Returns the index value of the first occurrence of the substring in the given string within the specified limit.
isalnum() Checks whether all the characters of the string are alphanumeric or not.
isalpha() Checks whether all the characters of the string are Alphabets (a-z or A-Z) or not.
isdecimal() Checks whether all the characters of the string are decimal (0-9) or not.
isdigit() Checks whether all the characters of the string are digits or not.

Share this Page

Meet the Author