Created
September 24, 2021 05:48
-
-
Save SaraM92/a3499e4f7df5078165963bf5dddb3ea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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