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:
def swap_case(s): list_s= list(s) for index,char in enumerate(list_s): if char == char.lower(): list_s[index] =char.upper() else: list_s[index]= char.lower() s = ''.join(list_s) return s string = 'HackerRank.com presents "Pythonist 2".' print(swap_case(string))