return res these functions work on any type of sequence--lists stringstuplesand other iterable objects that conform to the protocols expected by these functions (for loopsin membership testsin factwe can even use them on mixed object typesthe last two commands in the following test compute the intersection and union of list and tuple as usual in pythonthe object interface is what mattersnot the specific typesc:\pp \dstruct\basicpython from inter import "spams "scamintersect( )union( ([' '' '' '][' '' '' '' '' ']intersect([ , , ]( , )[ union([ , , ]( , )[ notice that the result is always list hereregardless of the type of sequences passed in we could work around this by converting types or by using class to sidestep this issue (and we will in momentbut type conversions aren' clear-cut if the operands are mixed-type sequences which type do we convert tosupporting multiple operands if we're going to use the intersect and union functions as general toolsone useful extension is support for multiple arguments ( more than twothe functions in example - use python' variable-length argument lists feature to compute the intersection and union of arbitrarily many operands example - pp \dstruct\basic\inter py "set operations for multiple sequencesdef intersect(*args)res [for in args[ ]for other in args[ :]if not in otherbreak elseres append(xreturn res def union(*args)res [for seq in argsfor in seqif not in resres append(xreturn res data structures scan the first list for all other arguments this item in each oneadd common items to the end for all sequence-arguments for all nodes in argument add new items to result