Error in program-censor(codecademy)Practice makes perfect : <p>I wanted to include spaces too while splitting the text, for that i looked up on google used import re</p>

<pre><code>import re
def censor(text,word) :
    text1=re.split(r"(\s+)",text)
    #print text1
    sum=""
    for i in range(0,len(text1)) :
        if text1[i]==word :
            for j in range(0,len(word)) :
                sum=sum+"*"
        else :
            sum=sum+text[i]
    return sum
</code></pre>

<p>The error I am getting is </p>

<p><a href="https://i.stack.imgur.com/OTIvu.png" rel="nofollow noreferrer">image displaying error and code</a></p>

<p>If I include an another for loop to replace every 'e' with a whitespace , it doesn't work.</p>
