Camel Case 4

  • + 0 comments

    I am able to solve this in python

    import re
    import sys
    
    def process_input(s_input):
        operation, type, words = map(str, s_input.split(';'))
        if operation == 'S':
            a = re.sub('([A-Z])', r' \1', words).lower().split()
            if type == 'M':
                a = a[:-2]
            print(" ".join(a))
        if operation == 'C':
            a = words.title().replace(' ', '')
            if type == 'V':
                a = a[:1].lower() + a[1:]
            elif type == 'M':
                a = a[:1].lower() + a[1:] + '()'
            print(a)
    
    if __name__ == "__main__":
        for line in sys.stdin:
            process_input(line.strip("\r\n"))