add two list code example
Example 1: calculate the addition of two lists in python
list1 = [1, 2, 3]
list2 = [4, 5, 6]
# `zipped_lists` contains pairs of items from both lists.
# Create a list with the sum of each pair.
sum = [x + y for (x, y) in zip(list1, list2)]
print(sum)
# [5, 7, 9]
Example 2: add two list in python
list1 = ["a", "b" , "c"]
list2 = [1, 2, 3]
list1.extend(list2)
print(list1)
Example 3: join lists python
first_list = ["1", "2"]
second_list = ["3", "4"]
# Multiple ways to do this:
first_list += second_list
first_list = first_list + second_list
first_list.extend(second_list)