You can download this code by clicking the button below.
This code is now available for download.
This function takes two lists as arguments and adds the corresponding elements of the lists together to return a new list. If the two lists are not of the same length, it returns an error message.
Technology Stack : List, Tuple, Iterator, zip function
Code Type : List manipulation function
Code Difficulty : Intermediate
def zipping_lists(list1, list2):
if len(list1) != len(list2):
return "Lists must be of the same length"
return [a + b for a, b in zip(list1, list2)]