Python: Add two given lists of different lengths, start from left
Add Lists from Left
Write a Python program to add two given lists of different lengths, starting on the left.
Sample Solution:
Python Code:
Sample Output:
Original lists: [2, 4, 7, 0, 5, 8] [3, 3, -1, 7] Add said two lists from left: [5, 7, 6, 7, 5, 8] Original lists: [1, 2, 3, 4, 5, 6] [2, 4, -3] Add said two lists from left: [3, 6, 0, 4, 5, 6]
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Python program to add two lists of different lengths from the left, treating missing elements as zeros.
- Write a Python program to add two lists from left and generate a new list where each element’s sum is multiplied by its index.
- Write a Python program to add two lists from left and produce both the element-wise sum and a carry list simulating addition with carrying over.
- Write a Python program to add two lists from left, stopping the addition process when a non-numeric element is encountered.
Go to:
Previous: Write a Python program to join two given list of lists of same length, element wise.
Next: Write a Python program to add two given lists of different lengths, start from right.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.