check 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")
Example 2: check if list is empty python
if len(li) == 0:
print('the list is empty')
Example 3: check if variable is empty python
if variable:
Example 4: how to tell if a list is empty in python
if not a:
print("List is empty")
Example 5: how to check empty string in python
my_empty_string = ''
def check_empty():
if not my_empty_string:
print("Empty")
else:
print("Not Empty")
check_empty()
Example 6: check if empty item in list python
if '' in list: