ezoic

Wednesday, February 22, 2017

overlapping


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-loops

class 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

looking for a man

 I am a mid aged woman.  I was born in 1980. I do not have any kid. no complicated  dating before . I am looking for a man here for marriage...