I\'m trying to solve this challenge in hackerrank, which asks to convert all lowercase letters to uppercase letters and vice versa.
I attempt it with the following code:
Try this
def swap_case(s): l =[] str1 = '' for i in s: if i.isupper(): l.append(i.lower()) elif i.islower(): l.append(i.upper()) else: l.append(i) return (str1.join(l)) if __name__ == '__main__': s = input() result = swap_case(s) print(result)