how to group lists per index in python
# initializing the list
lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# empty list
result = []
# variable to 0
index = 0
# iterating over the sub_list length (3) times
for i in range(len(lists[0])):
# appending an empty sub_list
result.append([])
# iterating lists length (3) times
for j in range(len(lists)):
# adding the element to the result
result[index].append(lists[j][index])
# moving to the next index
index += 1
# printing the result
print(result)