#!/usr/bin/python # popgrep1 - grep for abbreviations of places that say "pop" # version 1: slow but obvious way import fileinput import re popstates = ["CO","ON","MI","WI","MN"] for line in fileinput.input(): for state in popstates: if re.search(r"\b"+state+r"\b",line): print line