In this Hackerrank sWAP cASE problem, we need to develop a program that can take a string as input, and then we need to convert all the lowercase letters of that string into uppercase and uppercase to lowercase.

HackerRank sWAP cASE solution in python

Problem solution in Python 2 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
name = raw_input()
print ''.join(c.lower() if c.isupper() else c.upper() for c in name)

Problem solution in Python 3 programming.

def swap_case(s):
    return s.swapcase()

Problem solution in pypy programming.

def swap_case(s):
    res = ''
    for ch in s:
        if ch.isupper():
            res += ch.lower()
            res += ch.upper()
    return res

Problem solution in pypy3 programming.

def swap_case(s):
    result = []
    for letter in s:
        if letter == letter.lower():
        elif letter == letter.upper():
    return ''.join(result)