How to Solve NameError: name 'sample' is not defined -- random

Solution: Import the 'sample' module

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

from random import sample

 

For more information:
Python random sample