Menu Close

Swap lower case and upper case characters

Create a program to swap the lower case and upper case characters in a given string. Get the input string and swap the lower case with upper case and vice versa and print the string.

string1=input("Enter any string with mixed upper and lower case characters: ")
string2=list(string1)
for i in range(len(string2)):
	if(string2[i].isupper()==True):
		string2[i]=string2[i].lower()
	else:
		string2[i]=string2[i].upper()

print("Changed String: {}".format("".join(string2)))

Input:
Enter any string with mixed case characters:  fCUKtHEcODE

Output:
Changed String:  FcukTheCode


Exec. on linux

Morae!Q!