filterdef not_empty(s): return s and s.strip() t1 =list(filter(not_empty,['a','','b','c ',''])) print(t1)