How to resolve NameError: name ‘mystring’ is not defined error in python ?
I got below error message when executing my python script.
user@ngelinux$ ./fourth.py 5 5.199 Traceback (most recent call last): File "./fourth.py", line 13, inprint(mystring) NameError: name 'mystring' is not defined user@ngelinux$
Resolution
As the error says, the name “mystring” is not defined in the script.
Hence to resolve the issue define this variable in the script as follows:
### define the variable like below and print it. mystring="new string var" ### Now the issue is resolved.. user@ngelinux$ user@ngelinux$ ./fourth.py 5 5.199 hello 5.0 new string var user@ngelinux$