Sunday, November 23, 2025
HomeLanguagesPython string swapcase() Method

Python string swapcase() Method

Python String swapcase() method converts all uppercase characters to lowercase and vice versa of the given string and returns it.

Syntax: 

string_name.swapcase()  

Parameter: 

The swapcase() method does not take any parameter.

Return Value: 

The swapcase() method returns a string with all the cases changed. 

Example 

Below is the Python implementation of the swapcase() method 

Python




# Python program to demonstrate the use of
# swapcase() method 
 
string = "gEEksFORLazyroar"
 
# prints after swapping all cases
print(string.swapcase())  
 
string = "neveropen"
print(string.swapcase()) 
 
string = "GEEKSFORGEEKS"
print(string.swapcase())


Output: 

GeeKSforGEEKS
GEEKSFORGEEKS
neveropen
RELATED ARTICLES

Most Popular

Dominic
32410 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6909 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6865 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS