Python is designed at it's core to handle this tasks very easily. You don't need loops to merge, extract, split, lists.
List comprehensions are great to do this kind of operations on containers.
Generator expressions can be even more useful, usage depends on the context.
Here is an example of both:
array = [('a',1,'aa'), ('b',2,'bb'), ('c',3,'cc')]
sub_2 = [item[2] for item in array] # sub_2 is a classique list, with a length
gen_1 = (item[1] for item in array) # gen_1 is a generator, which gather value on the fly when requested
print(sub_2)
for i in gen_1:
print(i)
Output:
['aa', 'bb', 'cc']
1
2
3
You can write a utility function to help, but in simple cases, it's probably better to directly write the generator where you need it.
Here is an example of utility function you could write:
def sub(container, index):
return (item[index] for item in container)
print([i for i in sub(array, 0)])
Outputs ['a', 'b', 'c']