1my_str = ""
2if not my_str:
3 print("empty")
4else:
5 print("not empty")
6#output: empty
1my_empty_string = '' # given the empty string a variable
2
3def check_empty():
4 if not my_empty_string:
5 print("Empty")
6 else:
7 print("Not Empty")
8
9
10check_empty()
11
12
13
14# by George Kwabena
1variable = None
2variable_2 = ''
3variable_3 = 'string'
4variable_4 = 5
5
6def none_or_empty(variable):
7 return True if not variable else False
8
9none_or_empty(variable)
10none_or_empty(variable_2)
11none_or_empty(variable_3)
12none_or_empty(variable_4)