How to Solve NameError: name 'types' is not defined

Solution: Import the 'types' module

# Add the following line to the top of your code
import types

 

For more information:
Python types