sWAP cASE - Hackerrank Solution

 

Swap Case


Task:


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


Solution:

def change(s):
    if str.islower(s):
        return str.upper(s)
    else:
        return str.lower(s)
def swap_case(s):
    return ('').join(map(change,s))

if __name__ == '__main__':
    s = input()
    result = swap_case(s)
    print(result)

Note:

This Code is Verified by all Test Cases.If any error occurs then Comment correct code Below in comment box.

Disclaimer:-

 The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You. 


sWAP cASE - Hackerrank Solution sWAP cASE - Hackerrank Solution Reviewed by CodexRitik on March 24, 2020 Rating: 5

No comments:

Powered by Blogger.