In this HackerRank sWap cASE problem, we have given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.

HackerRank sWAP cASE in python problem solution

HackerRank sWAP cASE in python problem solution

s = input()

ns = ''

for letter in s:
    if letter.isupper():
        ns+= letter.lower()
    else:
        ns+= letter.upper()
        
print(ns)

Second solution

raw_line = input()
new_line = ''

for let in raw_line:
    if let.islower():
        new_line += let.upper()
    elif let.isupper():
        new_line += let.lower()
    else:
        new_line += let
    
        
print(new_line)