0% found this document useful (0 votes)
6 views

Python String Methods

The document provides an overview of five string methods in Python: upper(), lower(), strip(), replace(), and split(). Each method is described with its syntax and an example demonstrating its functionality. These methods are used for manipulating strings by changing case, removing whitespace, replacing substrings, and splitting strings into lists.

Uploaded by

Tarun Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Python String Methods

The document provides an overview of five string methods in Python: upper(), lower(), strip(), replace(), and split(). Each method is described with its syntax and an example demonstrating its functionality. These methods are used for manipulating strings by changing case, removing whitespace, replacing substrings, and splitting strings into lists.

Uploaded by

Tarun Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

upper()
The upper() method converts all lowercase letters in a string to upper

Syntax:
string.upper()

Example:
text = 'hello'
result = text.upper() # Output: 'HELLO'
2. lower()
The lower() method converts all uppercase letters in a string to lowerc

Syntax:
string.lower()

Example:
text = 'HELLO'
result = text.lower() # Output: 'hello'
3. strip()
The strip() method removes any leading and trailing whitespace from a

Syntax:
string.strip()

Example:
text = ' hello '
result = text.strip() # Output: 'hello'
4. replace()
The replace() method replaces a substring with another substring in a s

Syntax:
string.replace(old, new)

Example:
text = 'hello world'
result = text.replace('world', 'Python') # Output: 'hello Python'
5. split()
The split() method splits a string into a list of substrings based on a deli

Syntax:
string.split(delimiter)

Example:
text = 'a,b,c'
result = text.split(',') # Output: ['a', 'b', 'c']

You might also like