Skip to content
Related Articles

Related Articles

Python string | swapcase()

View Discussion
Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 05 Jan, 2018
View Discussion
Improve Article
Save Article

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

Syntax:

string_name.swapcase()
Here string_name is the string whose cases are to be swapped.

Parameter: The swapcase() method does not takes any parameter.

Return value:

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

Below is the Python implementation of the swapcase() method




# Python program to demonstrate the use of
# swapcase() method  
  
string = "gEEksFORgeeks"
  
# prints after swappong all cases
print(string.swapcase())   
  
string = "striver" 
print(string.swapcase())  

Output:

GeeKSforGEEKS
STRIVER
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!