← Back to challenges

Combine Arrays

PythonHardarraysdata_structuresloops

Instructions

Create a function that takes three lists and returns one list where all passed arrays are combined into nested lists.

These lists should be combined based on indexes: the first nested list should contain only the items on index 0, the second list on index 1, and so on.

If any list contains fewer items than necessary, supplement the missing item with "*".

Examples

combine_lists([False, "False"], ["True", True, "bool"], ["None", "undefined"]) ➞ [[False, "True", "None"], ["False", True, "undefined"], ["*", "bool", "*"]]

combine_lists([1, 2, 3], [4, 5, 6], [7, 8, 9]) ➞ [[1, 4, 7], [2, 5,  8], [3, 6, 9]]

combine_lists(["Jack", "Joe", "Jill"], ["Stuart", "Sammy", "Silvia"], ["Rick", "Raymond", "Riri"]) ➞ [["Jack", "Stuart", "Rick"], ["Joe", "Sammy",  "Raymond"], ["Jill", "Silvia", "Riri"]]

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.