;

Python Program to Toggle Characters Cases in a String using swapcase() Function


Tutorialsrack 28/04/2020 Python

In this Python Program, we will learn how to toggle character cases in a string using swapcase() function which is a python built-in function. The swapcase() function changes the lowercase to uppercase and uppercase to lowercase.

Here is the source code of the program to toggle character case in a string using swapcase() function which is a python built-in function.

Python Program to Toggle Characters Case in a String using swapcase() Function
# Python Program to Toggle Characters Case in a String using swapcase() Function

# Take the Input From the User
string = input("Enter the String: ")

string1 = string.swapcase()
 
print("\nOriginal String After Toggling Case :  ", string)
print("The Given String After Toggling Case  :  ", string1)

Output

Enter the String: Take the Input From the User

 

Original String After Toggling Case :   Take the Input From the User

The Given String After Toggling Case :   tAKE THE iNPUT fROM THE uSER

 

Enter the String: TuToRiaLsRaCk.CoM

 

Original String After Toggling Case :   TuToRiaLsRaCk.CoM

The Given String After Toggling Case :   tUtOrIAlSrAcK.cOm


Related Posts



Comments

Recent Posts
Tags