You can download this code by clicking the button below.
This code is now available for download.
This function takes two lists as arguments, uses the zip function to pair corresponding elements from the two lists, and then expands the paired results into lists of two elements using a list comprehension. If the input arguments are not lists, it returns None.
Technology Stack : Built-in function zip, list comprehension
Code Type : Function
Code Difficulty : Intermediate
def azip(arg1, arg2):
if isinstance(arg1, list) and isinstance(arg2, list):
return [z for x, y in zip(arg1, arg2) for z in (x, y)]
else:
return None