String Methods
Learn about the different string methods available in Python.
We'll cover the following...
Introduction to string methods
Here are some of the string methods available in the string
module (in alphabetical order):
-
string.center(int)
returns a copy ofstring
centered in a string of lengthint
. -
string.count(substring)
returns the number of non-overlapping occurrences ofsubstring
instring
. -
string.endswith(suffix)
returnsTrue
ifstring
ends withsuffix
. -
string.find(substring)
returns the index at the beginning of the first occurrence ofsubstring
instring
, or it returns -1 if not found. -
string.isalnum()
tests whether all characters are alphanumeric (letters or digits). It returnsTrue
if all characters are alphanumeric orFalse
...