- swapcase() is a python build-in function work only on the string data type.
- swapcase() is used to swap the alphabet case like if alphabet in string is in lowercase then it will become uppercase and similarly if alphabet in string are in uppercase then it will become in lowercase.
Syntax-
str.swapcase()
Example
string is "mytext"
it will give "MYTEXT"
string is "ALLTEXT"
it will give "alltext"
string is "MYtext"
it will give "myTEXT"
program-
s="this is proramming"
print(s.swapcase())
s="This is PROGRAMMING"
print(s.swapcase())
s="123"
print(s.swapcase())
s="THIS STRING IN UPPERCASE"
print(s.swapcase())
s="this string in lowercase"
print(s.swapcase())
THIS IS PRORAMMING
tHIS IS programming
123
this string in uppercase
THIS STRING IN LOWERCASE