Merge two or more lists into one list list , The elements in each input list are combined according to the position of each input list .
max()
To get the length of the longest list in the parameter .range()
Use with variables ,max_length
The number of cycles is as many as the elements in the longest list .max_length
, be fill_value
For remaining items def merge(*args, fill_value = None):
max_length = max([len(lst) for lst in args])
result = []
for i in range(max_length):
result.append([
args[k][i] if i < len(args[k]) else fill_value for k in range(len(args))
])
return result