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
1a_variable = {}
2
3is_a_empty = bool(a_variable)
4
5print(is_a_empty)
6# >>> False
7
8
9b_variable = [1, 2, 3]
10
11is_b_empty = bool(b_variable)
12
13print(is_b_empty)
14# >>> True