Define a function
overlapping()
that takes two lists and returns True if they have at least one member in common, False otherwise. You may use your is_member()
function, or the in
operator, but for the sake of the exercise, you should (also) write it using two nested for-loopsclass Solution:
def overlap(self,l1,l2):
bool1=0
for item in l1:
for item2 in l2:
bool1=bool1+bool(item==item2)
if bool1>0:
return('True')
else:
return('False')
kk=Solution()
if __name__=='__main__':
print(kk.overlap(['a','k','k'],['c','a','b']))
results:
No comments:
Post a Comment