yield tuple(resbecause this code uses iter and nextit works on any type of iterable note that there is no reason to catch the stopiteration raised by the next(itinside the comprehension here when any one of the argumentsiterators is exhausted--allowing it to pass ends this generator function and has the same effect that return statement would the while iterssuffices to loop if at least one argument is passedand avoids an infinite loop otherwise (the list comprehension would always return an empty listthis code works fine in python as islist(myzip('abc''lmnop')[(' '' ')(' '' ')(' '' ')but it falls into an infinite loop and fails in python xbecause the map returns one-shot iterable object instead of list as in in xas soon as we've run the list comprehension inside the loop onceiters will be exhausted but still true (and res will be []forever to make this work in xwe need to use the list built-in function to create an object that can support multiple iterationsdef myzip(*args)iters list(map(iterargs)rest as is allow multiple scans run this on your own to trace its operation the lesson herewrapping map calls in list calls in is not just for displaycomprehension syntax summary we've been focusing on list comprehensions and generators in this but keep in mind that there are two other comprehension expression forms available in both and set and dictionary comprehensions we met these briefly in and but with our new knowledge of comprehensions and generatorsyou should now be able to grasp these extensions in fullfor setsthe new literal form { is equivalent to set([ ])and the new set comprehension syntax { (xfor in if ( )is like the generator expression set( (xfor in if ( ))where (xis an arbitrary expression for dictionariesthe new dictionary comprehension syntax {keyval for (keyvalin zip(keysvals)works like the form dict(zip(keysvals))and {xf(xfor in itemsis like the generator expression dict((xf( )for in itemshere' summary of all the comprehension alternatives in and the last two are new and are not available in and earlier[ for in range( )[ comprehensions and generations list comprehensionbuilds list like list(generator expr