The Wayback Machine - https://web.archive.org/web/20230512160717/https://www.geeksforgeeks.org/python-string-swapcase/
Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python string swapcase() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 = "gEEksFORgeeks"
 
# prints after swapping all cases
print(string.swapcase())  
 
string = "geeksforgeeks"
print(string.swapcase()) 
 
string = "GEEKSFORGEEKS"
print(string.swapcase())

Output: 

GeeKSforGEEKS
GEEKSFORGEEKS
geeksforgeeks
My Personal Notes arrow_drop_up
Last Updated : 13 Mar, 2023
Like Article
Save Article
Related Tutorials