Solution to List Overlap using functions in Python

Here is the solution to List Overlap using functions in Python which is given below:

def listOverlap(num1, num2):
final_list = [ ]
for num in num1:
if num in num2:
final_list.append(num)
return final_list

a = [ ]
b = [ ]

n = int(input("Enter number of elements : "))

for i in range(0, n):
ele = int(input())
a.append(ele)

n1 = int(input("Enter number of elements : "))

for j in range(0, n1):
ele1 = int(input())
b.append(ele1)

print("The common elements in the two lists are: ")
print(listOverlap(a, b))