String methods

An example of using a string method:

s = "Hello World"
s = s.replace("World","Python")
print(s)

Overview
Python includes these useful methods for string manipulation:

Method with description
capitalize(str)
Returns first letter capitalized string.
count(str)
Count the frequency of the word str. It can also be applied to words: s.count(“Hello”)
find(str)
Find the position of the first occurence.
index(str)
Find the position of the first occurence, raise exception if not found.
isdecimal()
Returns true if string is decimal.
isdigit()
Returns true if string contains digits only.
isnumeric()
Returns true if string contains numeric only.
lower()
Returns string in lowercase.
len(str)
Returns the length of str.
upper()
Returns string in uppercase.
replace(old, new)
Replaces the first argument with the second argument.