How to Solve NameError: name 'getopt' is not defined -- getopt

Solution: Import the 'getopt' module

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

 

For more information:
getopt getopt