Example of NameError exception

Example of NameError exception

Lesson Details:
June 29, 2020

I: Introduction

A: Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java. The language provides constructs intended to enable clear programs on both a small and large scale.

Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a fully dynamic type system and automatic memory management and has a large and comprehensive standard library.

II: Body

A: Example of nameerror exception

In a programming language like Python, where there are no reserved words (such as if, then, else or for), it is possible that you will use an identifier that was already assigned to some other function/command/variable.

If the identifier was assigned to something that is not used anymore (i.e. no longer in use) the IDE will tell you that you are using an undefined name. This is called NameError (or Name Undefined).

III: Conclusion

A: As you can see, there is nothing more frustrating than receiving this message while coding in Python, especially if you are new to this language. Fortunately, there are several ways to resolve this error. You can either assign some value to the identifier or re-assign the identifier to something else.

Course content