Python - String/object Null check

Use the following code to check for null string in Python.

if (not name)
   name = "techdive";
else
    print(name);  

To check for null objects use the following code.

if (name is None)
   name = "techdive";
elif (name is not None)
    print (name);  

Search