sWAP cASE

Sort by

recency

|

1996 Discussions

|

  • + 0 comments

    def swap_case(s):

    new_s = ''
    for i in s:
        if i.isupper():
            new_s += i.lower()
        elif i.islower():
            new_s += i.upper()    
        else:
            new_s += i   
    
    return new_s
    
  • + 0 comments

    def swap_case(s): c=s.split() d="" e=[] for j in list(c): for i in j: if i.islower(): d+=i.upper() elif i.isupper(): d+=i.lower() else: d+=i d+=" " e.append(d) for k in e: return k

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

  • + 0 comments
    def swap_case(s):
        result = ""
        for ele in s:  
            if (ord(ele) in range(65, 92)):
                result += chr(ord(ele)+32)
            elif (ord(ele) in range(97, 123)):
                result += chr(ord(ele)-32)
            else:
                result += ele
        return result
    
  • + 0 comments

    HOW TO DO THE SWAP CASE THING?

  • + 0 comments

    we can use the simple swapcase function to do it

    def swap_case(s):

    return s.swapcase()
    

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