Wednesday, 14 February 2024

Class 11 CS Practical - 32

 

32 - Write a program in Python to input a string and convert the case of characters (uppercase to lowercase and lowercase to uppercase) in the string. 


S=input("Enter a string: ")

NS=''

for i in range(0,len(S)):

    if S[i].isupper():

        NS+=S[i].lower()

    elif S[i].islower():

        NS+=S[i].upper()

    else:

        NS+=S[i]

print("New String = ",NS)


Output:

Enter a string: Python @ PrograMMing

New String =  pYTHON @ pROGRAmmING



No comments:

Post a Comment