Python string | swapcase()

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

GeeKSforGEEKS
STRIVER


My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.