Camel Case 4

  • + 0 comments

    My Python3 solution:

    import sys
    all_inp = sys.stdin.read().split('\r\n')
    
    for e in all_inp:
        if e[0] == 'S':
            s = e[4].lower()
            for i, l in enumerate(e[5:]):
                if l.isupper():
                    s += ' '+l.lower()
                else: s += l.lower()
            print(s if e[2] != 'M' else s[:-2]) 
        else:
            s = e[4].lower() if e[2] != "C" else e[4].upper() 
            for i, l in enumerate(e[5:]):
                if l == ' ':
                    continue
                if e[i+(5-1)] == ' ':
                    s += l.upper()
                else:
                    s += l.lower()
            print(s if e[2] != 'M' else s+'()')