Question: Python Question Write a function add_list(lst1, lst2) that takes two lists of numbers of the same length and returns a list consisting of the sum

Python Question

Write a function add_list(lst1, lst2) that takes two lists of numbers of the same length and returns a list consisting of the sum of the first numbers, the sum of the second numbers, etc. For example, add_list([1,2,3], [4,5,6]) should return the list [5, 7, 9] since 1+ 4 is 5, 2 + 5 is 7, etc.

Your main program should prompt user for input. It should read a list of numbers, one number per line, followed by done, then another list of numbers, one per line, followed by done. If the lists have different lengths, your main program should print Lists are different lengths. If they are the same length, the main program should call add_list and print the resulting list, one number per line.

Note: you may define additional functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!