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

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -