sWAP cASE - HackerRank String Problem

sWAP cASE - HackerRank String Problem

Instructor-svgAl-Mamun Sarkar
Mar 23 , 2020

sWAP cASE - HackerRank String Problem. Swap the case of the given string. Click here to see the problem on HackerRank

Code:

def swap_case(s):
    new_st = "";
    for c in s:
        if c.islower():
            new_st += c.upper()
        elif c.isupper():
            new_st += c.lower()
        else:
            new_st += c
    return new_st


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

Input:

ArtOfCse.com

Output:

aRToFcSE.COM
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram