python pop list items with condition code example

Example 1: how to pop things out of list python

>>> l = ['a', 'b', 'c', 'd']
>>> l.pop(0)
'a'
>>> l
['b', 'c', 'd']

Example 2: python filter remove from list

# Say you have the array ['', 'foo', '.', 'bar', 'foo', '', 'bar']
# and you want to remove the empty characters and periods. You do:
  
tokens = filter(isImportant, array) 

for token in tokens:
  print(token)
  
# prints:
# > foo
# > bar
# > foo
# > bar

def isImportant(token):
	if token == '' or token == '.':
      return False
    return True