Use set.instersection() instead of a for loop.