if we have double spaces at the end of the string then issue of out of bound would arise.
possible solution :
`elif(extraspaceremover=="on"):
analyzed=re.sub(' +',' ', djtext)
params = {'purpose': 'Removed NewLines', 'analyzed_text': analyzed}
# Analyze the text
return render(request, 'analyze.html', params)`