How to Solve NameError: name 'capwords' is not defined -- string
Solution: Import the 'capwords' module
To Solve the error, add the following line to the top of your code.
from string import capwords
For more information:
Python string capwords