Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- m = [5,2,6,9,5,2,65,6,5,5,5,5,5]
- k = [x for x in range(0,random.randint(0,90))] # using random.randint() to generate a random list
- common_list = [x for x in m for y in k if x == y] # using list comprehension to seek common elements from the list
- new_set = set(k) # using the set constructor to convert the list into the set so there will be no duplicatopn of the element
- final_list = list(new_set) # converting back into list
- print(final_list)
Advertisement
Add Comment
Please, Sign In to add comment