python - How to check if an element in the list exists in another list -
how check if element in list exists in list?and if append list.how can make values in list?
common=[] def findcommon(interactor,interactor1): in interactor: if in interactor1: common.append(a) return common interactor=['rishi kapoor','kalkidan','aishwarya'] interactor1=['aishwarya','suman ranganathan','rishi kapoor']
you can using list comprehensions:
common = [x x in iter_actor1 if x in iter_actor2]
or using sets:
common = set(iter_actor1).intersection(iter_actor2)
Comments
Post a Comment