sWAP cASE

Sort by

recency

|

1973 Discussions

|

  • + 0 comments

    def swap_case(s): l =[] for char in s: if char.islower(): char = char.upper() l.append(char) elif char.isupper(): char =char.lower() l.append(char) else: l.append(char)
    l1 =''.join(l)

    return l1
    

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

  • + 0 comments
    chars = []
    def swap_case(s):
            for c in s:
                if c.isupper():
                    chars.append(c.lower())
                else:
                    chars.append(c.upper())
    
            return ''.join(chars)  # convert array to string using join()
    
  • + 0 comments

    The most easy way would be using swapcase() function but i would say is worth to check the following functions ->

    Explanation: char.isupper(): Checks if a character is uppercase. char.lower(): Converts an uppercase character to lowercase. char.upper(): Converts a lowercase character to uppercase. join(): Combines the transformed characters into a new string.

    This method avoids using .swapcase() and achieves the same result.

  • + 0 comments

    The most easy way would be using swapcase() function but i would say is worth to check the following functions ->

    Explanation: char.isupper(): Checks if a character is uppercase. char.lower(): Converts an uppercase character to lowercase. char.upper(): Converts a lowercase character to uppercase. join(): Combines the transformed characters into a new string.

    This method avoids using .swapcase() and achieves the same result.

  • + 0 comments

    The most easy way would be using swapcase() function but i would say is worth to check the following functions ->

    Explanation: char.isupper(): Checks if a character is uppercase. char.lower(): Converts an uppercase character to lowercase. char.upper(): Converts a lowercase character to uppercase. join(): Combines the transformed characters into a new string.

    This method avoids using .swapcase() and achieves the same result.