sWAP cASE

Sort by

recency

|

1963 Discussions

|

  • + 0 comments

    By using swapcase() this problem can be solved with one line of code.

    code>> def swap_case(s): ex = s.swapcase() return ex

  • + 0 comments
        c=''.join([s[i].lower() if s[i].isupper() else s[i].upper()  for i in range(len(str(s)))])
        return c       
    
  • + 0 comments

    def swap_case(s): new_string = '""

    for i in s:
        if i.isupper():
            i = i.lower()
            new_string = new_string + i
        elif i.islower():
            i = i.upper()
            new_string = new_string + i
        else:
            new_string = new_string + i
    
    return new_string
    
  • + 0 comments
    def swap_case(s):
        return s.swapcase()
    
    if __name__ == '__main__':
        s = input()
        result = swap_case(s)
        print(result)
    
  • + 0 comments

    def swap_case(s): s1 = [i.lower() if i.isupper() else i.upper() for i in s] s1= "".join(s1) return s1