Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

val = "" 

del val 

if val is None: 

print("null")

I ran above code but got NameError: name 'val' is not defined.

How to decide whether a variable is null, and avoid NameError?

1 Answer

0 votes
by (106k points)

You can check if val is None by using the below mentioned piece of code:-

if val is None: 

pass 

To know more about this you can have a look at the following video tutorial:-


 

Related questions

+1 vote
1 answer
0 votes
1 answer
0 votes
2 answers
asked Jul 13, 2019 in Python by Sammy (47.6k points)

Browse Categories

...