Skip to content

Instantly share code, notes, and snippets.

@SaraM92
Created September 24, 2021 05:48
Show Gist options
  • Save SaraM92/a3499e4f7df5078165963bf5dddb3ea3 to your computer and use it in GitHub Desktop.
Save SaraM92/a3499e4f7df5078165963bf5dddb3ea3 to your computer and use it in GitHub Desktop.
def merge(*args, missing_val = None):
#missing_val will be used when one of the smaller lists is shorter tham the others.
#Get the maximum length within the smaller lists.
max_length = max([len(lst) for lst in args])
outList = []
for i in range(max_length):
result.append([args[k][i] if i < len(args[k]) else missing_val for k in range(len(args))])
return outList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment