Posts

Showing posts with the label Swapcase in python

Swapcase in python

Image
Swap case in python The program gets a string as input from the user and converts all the lower case letters to upper case and all upper case letters to lower case. For example, Sample input : Hello Everyone Sample output : hELLO eVERYONE Explanation : In the above sample, for the string “Hello Everyone”, the characters “H” and “E” is in upper case and the rest characters are in lowercase. So the output should be “hELLO eVERYONE” where the characters “h” and “e” are alone in lower case and the rest characters are in upper case. Method 1 (without using swap case function) Procedure : 1. Start. 2. Get the string as input from the user. 3. Initialize the swapped string. 4. loop ( 0 to len(string) )     => check if the character is in lower case.          => subtract 32 from the ASCII value of the character.     => check if the character is in upper case.          => add 32 to the ASCII value of the character.     => convert the ascii value to character and