Question::
Define a function is_common() that takes two lists and returns True if they have at least one member in common, False otherwise.
Code::
def is_common(d,n):
for i in d:
for j in n:
if(j==i):
return True
return False
n=input("Enter list: ")
nt=n.split(",")
d=input("Enter another list: ")
dm=d.split(",")
if(is_common(dm,nt)):
print("Yes There are Common Elements")
else:
print("No There are no Common Elements")
Output::
Define a function is_common() that takes two lists and returns True if they have at least one member in common, False otherwise.
Code::
def is_common(d,n):
for i in d:
for j in n:
if(j==i):
return True
return False
n=input("Enter list: ")
nt=n.split(",")
d=input("Enter another list: ")
dm=d.split(",")
if(is_common(dm,nt)):
print("Yes There are Common Elements")
else:
print("No There are no Common Elements")
Output::