Error:Python:type exceptions.NameError

From IPRE Wiki
Revision as of 15:45, 21 March 2011 by Doug Blank (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Cause

This error occurred because you referred to a variable that doesn't exist yet.

Solution

Make sure that variables are defined with an initial value.

Consider this code:

x = x + 1

If x were not previously defined, then it would cause this error. the solution is to provide an initial value for x:

x = 0
x = x + 1