sWAP cASE

  • + 0 comments
    def swap_case(s):
        my_list = []
        for i in s:
            if 65 <= ord(i) <= 90:
                i = chr(ord(i) + 32)
                my_list.append(i)
            elif 97 <= ord(i) <= 122:
                i = chr(ord(i) - 32)
                my_list.append(i)
            else:
                my_list.append(i)
        return ''.join(my_list)
    
    if __name__ == '__main__':
        s = input()
        result = swap_case(s)
        print(result)