good nor general--we' still have to edit each copy to support different sequence namesand changing the algorithm would then require changing multiple copies definition by nowyou can probably guess that the solution to this dilemma is to package the for loop inside function doing so offers number of advantagesputting the code in function makes it tool that you can run as many times as you like because callers can pass in arbitrary argumentsfunctions are general enough to work on any two sequences (or other iterablesyou wish to intersect when the logic is packaged in functionyou have to change code in only one place if you ever need to change the way the intersection works coding the function in module file means it can be imported and reused by any program run on your machine in effectwrapping the code in function makes it general intersection utilitydef intersect(seq seq )res [for in seq if in seq res append(xreturn res start empty scan seq common itemadd to end the transformation from the simple code of to this function is straightforwardwe've just nested the original logic under def header and made the objects on which it operates passed-in parameter names because this function computes resultwe've also added return statement to send result object back to the caller calls before you can call functionyou have to make it to do thisrun its def statementeither by typing it interactively or by coding it in module file and importing the file once you've run the defyou can call the function by passing any two sequence objects in parenthesess "spams "scamintersect( [' '' '' 'strings herewe've passed in two stringsand we get back list containing the characters in common the algorithm the function uses is simple"for every item in the first argumentif that item is also in the second argumentappend the item to the result it' little shorter to say that in python than in englishbut it works out the same second exampleintersecting sequences