MWZ

MINDWAREZONE

String Methods

String methods are built-in functions used to manipulate strings.

Common Methods

Method Description
upper() Converts to uppercase
lower() Converts to lowercase
strip() Removes spaces from both ends
replace() Replaces text
split() Splits string into a list

Example 1:

text = "python"
print(text.upper())
            

Output

PYTHON
            

Example 2:

text = "PYTHON"
print(text.lower())
            

Output

python
            

Example 3:

sentence = "I love Python"
print(sentence.replace("Python", "Programming"))
            

Output

I love Programming