File: class/Workbook/Examples/Lecture5/intersect0.py

def intersect(seq1, seq2):
    res = []                     # start empty
    for x in seq1:               # scan seq1
        if x in seq2:            # common item?
            res.append(x)        # add to end
    return res



[Home page] Books Code Blog Python Author Train Find ©M.Lutz