Introducing List Filtering : List Filter « List « Python






Introducing List Filtering

Introducing List Filtering
li = ["a", "mpilgrim", "foo", "b", "c", "b", "d", "d"] 

print [elem for elem in li if len(elem) > 1]            

print [elem for elem in li if elem != "b"]               

print [elem for elem in li if li.count(elem) == 1]       
           
       








Related examples in the same category