Camel Case 4

  • + 0 comments
    import sys
    while True:
        line=sys.stdin.readline().strip()
        if not line:
            break
        Input=line.split(";")
        operation=Input[0]
        Type=Input[1]
        word=Input[2]
        if operation=="S":
            res=""
            for i in word:
                if i.isupper() and not res:
                    res+=i.lower()
                elif i.isupper() and res:
                    res+=" "+i.lower()
                elif i=="("or i==")":
                    continue
                else:
                    res+=i
            print(res)
        elif operation=="C":
            String=word.split()
            res=String[0].lower()
            if Type=="C":
                res=res.capitalize()
            for i in String[1:]:
                res+=i.capitalize()
            if Type=="M":
                res+="()"
            print(res)