if is_empty python code example
Example 1: check if string is empty python
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
Example 2: check if variable is empty python
if variable:
# code goes here...
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
if variable:
# code goes here...