Camel Case 4

  • + 0 comments

    def camelCasing(word): if word[0] == 'S': #Split Operation new_word = word[4:] result = ''

        if word[2] == 'V':          #For Variables
            for letter in new_word:
                if letter.isupper():
                   result += ' ' + letter.lower()
                else: 
                    result += letter
            print(result)
    
        elif word[2] == 'M':            #For Methods
            for letter in new_word:
                if letter.isupper():
                   result += ' ' + letter.lower()
                elif letter == '(':
                    result = result
                elif letter == ')':
                    result = result    
                else:
                    result += letter
            print(result)        
    
        elif word[2] == 'C':            #For Classes
            new_word = new_word[0].lower() + new_word[1:]
            for letter in new_word:
                if letter.isupper():
                   result += ' ' + letter
                else:
                    result += letter   
            fresult = result.lower()       
            print(fresult)
    
    if word[0] == 'C':          #Combine Operations
        n_word = word[4:]
        new_word = n_word.split()
        result = ''
    
        if word[2] == 'V':          #For Variables
            result += new_word[0].lower() + ''.join(letter.capitalize() for letter in new_word[1:])
            print(result)
    
        if word[2] == 'M':          #For Methods
            result += new_word[0].lower() + ''.join(letter.capitalize() for letter in new_word[1:])
            result +='()'
            print(result)
    
        if word[2] == 'C':          # For Classes
            for letter in new_word:
                result = ''.join(letter.capitalize() for letter in new_word)
            print(result)
    

    if name == 'main': import sys

    input_lines = sys.stdin.read().strip().split('\n')  # Read all input lines
    for line in input_lines:
        camelCasing(line)