The below code belongs to NLTK regex:
import nltk
nltk.download('punkt')
from nltk.tokenize import word_tokenize
from nltk.tokenize import sent_tokenize
scene = "Hello how! how are you? what is your problem. Can I solve with 00code for you/ by the way bye. Take care"
match_index = print(re.search("you",scene))
print(match_index.start(),match_index.end())
Error I got is:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-54-5e13e5437c3e> in <module>()
----> 1 print(match_index.start(),match_index.end())
AttributeError: 'NoneType' object has no attribute 'start'
I have included its library but still, it is showing an error. What are the ways I can handle this error?
print
returns None, so after this line,match_index
is None.Try assigning and printing on separate lines.
Result: