You get a NameError
if you use a variable that does not exist:
print(x)
Try it Yourself » Definition and UsageThe NameError
exception occurs if you use a variable that is not defined.
You can handle the NameError
in a try...except
statement, see the example below.
Handling the NameError
in a try...except
statement:
try:
print(x)
except NameError:
print("Variable x is not defined")
except:
print("Something else went wrong")
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4