sWAP cASE

Sort by

recency

|

1984 Discussions

|

  • + 0 comments

    def swap_case(s): r="" for i in s: if(i==i.lower()): r+=i.upper() elif(i==i.upper()): r+=i.lower() else: r+=i result r

  • + 0 comments
    def swap_case(s):
        txt = ""
        for char in s:
            if char.isupper():
                txt += char.lower()
            else:
                txt += char.upper()
        return txt  
    
  • + 0 comments

    There is a method in python by which is swap_case(). You can use this instead of boring coding.

    def swap_case(s):
        return s.swapcase()
    
    if __name__ == '__main__':
        s = input()
        result = swap_case(s)
        print(result)
    
  • + 0 comments

    def swap_case(s): result ="" for i in s: if i.islower(): result += i.upper() else : result += i.lower() return result

    if name == 'main': s = input() result = swap_case(s) print(result)

  • + 0 comments

    def swap_case(s): swap = "" for char in s: if char.isupper(): swap = swap + char.lower() else: char.islower() swap = swap + char.upper() return swap