how to edit each member of a list in python
I am new to python and I am trying to create a capitalize function that either capitalizes all words in a string or only the first word. Here is my function

    def capitalize(data, applyToAll=False):
    """depending on applyToAll it either capitalizes
       all the words in the string or the first word of a string"""

    if(type(data).__name__ == "str"):

        wordList = data.split()

        if(applyToAll == True):
            
            for word in wordList:
                wordList[word] = word.capitalize() #here I am stuck!
                
            return " ".join(wordList)
        
        else: return data.capitalize()

    else: return data

So basically, I want to edit the item but I don't know how I can do it. 

Btw, this is an optional question: in c# I had the chance to debug my code, what do yo guys use in python to debug?
how to edit each member of a list in python
===

I am new to python and I am trying to create a capitalize function that either capitalizes all words in a string or only the first word. Here is my function

    def capitalize(data, applyToAll=False):
    """depending on applyToAll it either capitalizes
       all the words in the string or the first word of a string"""

    if(type(data).__name__ == "str"):

        wordList = data.split()

        if(applyToAll == True):
            
            for word in wordList:
                wordList[word] = word.capitalize() #here I am stuck!
                
            return " ".join(wordList)
        
        else: return data.capitalize()

    else: return data

So basically, I want to edit the item but I don't know how I can do it. 

Btw, this is an optional question: in c# I had the chance to debug my code, what do yo guys use in python to debug?