다른 언어에서는 isEmpty() 메소드를 제공하거나, 리스트의 길이가 0인지를 비교하여 empty를 확인한다.
그런데 파이썬의 if문은 empty list일 경우 False를, empty list가 아닐 경우 True를 리턴한다
list1 = []
list2 = [1, 2, 3, 4]
if not list1:
print("empty")
if list2:
print("not empty")
다른 언어에서는 isEmpty() 메소드를 제공하거나, 리스트의 길이가 0인지를 비교하여 empty를 확인한다.
그런데 파이썬의 if문은 empty list일 경우 False를, empty list가 아닐 경우 True를 리턴한다
list1 = []
list2 = [1, 2, 3, 4]
if not list1:
print("empty")
if list2:
print("not empty")