How to Solve NameError: name 'chain' is not defined -- itertools

Solution: Import the 'chain' module

# Add the following line to the top of your code
from itertools import chain

 

For more information:
itertools chain