append to two list python code example
Example 1: append two items to list
my_list = ['a']
# You can use list.append(value) to append a single value:
my_list.append('b')
# my_list should look like ['a','b']
# and list.extend(iterable) to append multiple values.
my_list.extend(('b','c'))
# my_list should look like ['a','b','c']
Example 2: python add elements of two lists together
list1 = [1, 2, 3]
list2 = [4, 5, 6]
sum_list = []
for (item1, item2) in zip(list1, list2):
sum_list.append(item1 + item2)
print(sum_list)