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

R is not a simple programming language, and it does better on reading excel files than python

R is not a simple programming language, and it does better on reading excel files than python . tried to read excel files to python and R. i...