파이썬 빈 목록 제거
list2 = filter(None, list1)
파이썬 목록에서 빈 문자열 제거
def compact(lst):
return list(filter(None, lst))
compact([0, 1, False, 2, '', 3, 'a', 's', 34]) # [ 1, 2, 3, 'a', 's', 34 ]
목록 파이썬에서 빈 요소를 제거하는 방법
without_empty_strings = [string for string in a_list if string != ""]