How to Solve NameError: name 'digits' is not defined -- string

Solution: Import the 'digits' module

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

from string import digits

 

For more information:
Python string digits