How to Solve NameError: name 'sub' is not defined -- re

Solution: Import the 'sub' module

To Solve the error, add the following line to the top of your code.

from re import sub

 

For more information:
Python re sub