A = [“a”,”b”,” “,”c”,” “,”d”] How can I remove str. Of white spaces from this list 🤔
Advertisement
Answer
A = [s for s in A if s.strip() != ”]
or
A = [s for s in A if len(s.strip()) > 0]
A = [“a”,”b”,” “,”c”,” “,”d”] How can I remove str. Of white spaces from this list 🤔
A = [s for s in A if s.strip() != ”]
or
A = [s for s in A if len(s.strip()) > 0]