String Swap Case in Python

Use the swapcase() method to transform the upper case characters into a lower case and vice versa.

regular_text = "This IS a reguLar text."

swapped_case_text = regular_text.swapcase()

print(regular_text)
#This IS a reguLar text.

print(swapped_case_text)
#tHIS is A REGUlAR TEXT.

Notice that the original regular_text variable remains unchanged, thus you need to assign the return of the method to a new variable, swapped_case_text in this case.