vocab = ['dog', 'lazy', 'the', 'fly']

def my_filter(s):
    if len(s) > 5:
        return False
if not s.islower():
    return False
if s not in vocab:
    return False
return True

def modify(s, x):
    s += x
return s
slist = ['the', 'dog', 'jumps', 'over', 'the', 'fly']
slist = map(modify, list(filter(my_filter, slist)))
Simplifying / optimizing a chain of for-loops