Sunday, June 28, 2020

sWAP cASE-HackerRank Solution

 sWAP cASE-HackerRank Solution

 You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.

For Example:

Www.HackerRank.com → wWW.hACKERrANK.COM
Pythonist 2 → pYTHONIST 2

Input Format

A single line containing a string .

Constraints

Output Format

Print the modified string .

Sample Input 0

HackerRank.com presents "Pythonist 2".

Sample Output 0

hACKERrANK.COM PRESENTS "pYTHONIST 2".
Swap Case Solution-
def swap_case(s):
    return s.swapcase() #interchange the character of string from uppercase to lowercase or vice-versa
if __name__ == '__main__':
    s = input()
    result = swap_case(s)
    print(result)

0 comments:

Post a Comment

Feel free to share your thoughts and suggestion...