How to Solve NameError: name 'stdout' is not defined -- sys

Solution: Import the 'stdout' module

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

from sys import stdout

 

For more information:
Python sys stdout