티스토리 뷰

공부

[Python] remove "" filter(None, lst)

승가비 2022. 6. 6. 02:55
728x90
>>> lst = ["He", "is", "so", "", "cool"]
>>> filter(None, lst)
['He', 'is', 'so', 'cool']

https://stackoverflow.com/questions/16099694/how-to-remove-empty-string-in-a-list

 

How to remove empty string in a list?

For example I have a sentence "He is so .... cool!" Then I remove all the punctuation and make it in a list. ["He", "is", "so", "", "cool"] How do I remove or ignore the empty string?

stackoverflow.com

 

728x90

'공부' 카테고리의 다른 글

[MySQL] created_at, updated_at  (0) 2022.06.06
[docker-compose] environment. LC_ALL=ko_KR.UTF-8  (0) 2022.06.06
[Python] remove "" filter(None, lst)  (0) 2022.06.06
[Python] strip in map function  (0) 2022.06.06
[Kotlin] destructure array  (0) 2022.06.06
[spring] @Cachable  (0) 2022.06.06
댓글
댓글쓰기 폼