Skip to content
Home » NameError: name ‘re’ is not defined

NameError: name ‘re’ is not defined

To solve NameError: name ‘re’ is not defined error follow below methods.

ERROR LOG

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    patFinderTitle = re.compile('<title>(.*)</title>')
NameError: name 're' is not defined

How to solve NameError: name ‘re’ is not defined ?

Refer the given methods to solve the issue.

In the order to use regular expression, first you need to import it. Initially import re the try to use them.

import re
re.compile('<title>(.*)</title>')

Hope the above solution works.

Also read :

TypeError: ‘int’ object is not callable
RuntimeError: dictionary changed size during iteration