games = [ [102, 51], [78, 67], [53, 94], [64, 75], [54, 71], [64, 68] ] # an initial solution results = [] for p in games: if p[0] > p[1]: # 1. if p meets a condition results.append(p) # 2. record it in our result # factor out the test as a function def home_team_won(p): return p[0] > p[1] # and use the function results = [] for p in games: if home_team_won(p): # 1. if p meets a condition, in a fxn results.append(p) # 2. record it in our result # filter does all of this -- as long as you give it home_team_won() results = filter(home_team_won, games) # like map, filter produces a "filter object" that we can loop over # # for r in results: # print(r) # # ... but it is a "use once" object!