I think line 34 should be tokens_capitalized = [token[0].upper()+token[1:].lower() for token in tokens if len(token)>1] instead of tokens_capitalized = [token[0].upper()+token[1:].lower() for token in tokens. It helps to resolve the "string index out of range" issue
I think line 34 should be
tokens_capitalized = [token[0].upper()+token[1:].lower() for token in tokens if len(token)>1]
instead oftokens_capitalized = [token[0].upper()+token[1:].lower() for token in tokens
. It helps to resolve the "string index out of range" issue