Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #This is a code that returns a list that contains only the common elements between two lists without duplicate
  2. def listsintersct(L1,L2):
  3. T=[]
  4. D=[]
  5. if len(L1)>=len(L2):
  6. for i in range(len(L2)):
  7. if L2[i] in L1:
  8. T+=[L2[i]]
  9. else:
  10. for i in range(len(L1)):
  11. if L1[i] in L2:
  12. T+=[L1[i]]
  13. for c in T:
  14. if c not in D:
  15. n=0
  16. for j in range(len(T)):
  17. if c==T[j]:
  18. n+=1
  19. D+=[c]
  20. return D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement