Sunday, March 3, 2019

Addition of two list using User define function - Python3

def add_list(list1, list2):
        sum_list = []
        for i in range(len(list1)):
            sum_list.append(int(list1[i]) + int(list2[i]))
        return sum_list
    
n = int(input("Enter the value of n: "))
list1 = []
print ("Enter the elements of list a: ")
for i in range(n):
    list1.append(input())
         
list2 = []
print ("Enter the elements of list b: ")
for i in range(n):
    list2.append(input()) 

print(add_list(list1, list2))

ScreenShots:

No comments:

Post a Comment