Python: Join two given list of lists of same length, element wise
Join Two Lists of Lists Element-Wise
Write a Python program to join two given list of lists of the same length, element wise.
Sample Solution:
Python Code:
Sample Output:
Original lists: [[10, 20], [30, 40], [50, 60], [30, 20, 80]] [[61], [12, 14, 15], [12, 13, 19, 20], [12]] Join the said two lists element wise: [[10, 20, 61], [30, 40, 12, 14, 15], [50, 60, 12, 13, 19, 20], [30, 20, 80, 12]] Original lists: [['a', 'b'], ['b', 'c', 'd'], ['e', 'f']] [['p', 'q'], ['p', 's', 't'], ['u', 'v', 'w']] Join the said two lists element wise: [['a', 'b', 'p', 'q'], ['b', 'c', 'd', 'p', 's', 't'], ['e', 'f', 'u', 'v', 'w']]
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Python program to join two lists of lists element-wise by aligning based on the shortest inner list length.
- Write a Python program to merge two lists of lists element-wise by padding shorter lists with a default value.
- Write a Python program to combine two lists of lists element-wise and then flatten the resulting structure into a single list.
- Write a Python program to interlace two lists of lists element-wise where one list contains numbers and the other contains strings, concatenating corresponding elements.
Go to:
Previous: Write a Python program to check if a given element occurs at least n times in a list.
Next: Write a Python program to add two given lists of different lengths, start from left.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.