checking for common elements in 2 lists

def common_list_func(list1,list2):
    # write your code here
  if i  in list1 = i in list2:


  return common_items_list

print(common_list_func([1,2,3,4],[3,4,5])) # should print [3,4]

this is question 2 and i am not able to figure out how to check which elements in 2 lists are same

Before we think about your correct answer, let me ask you this question
what does the below code mean which you have written

1 Like

yes i know it is incorrect,i tried writing j in list2 also,it did not work

def common_list_func(list1,list2):

common= list(set(list1).intersection(set(list2)))

return common_item_list


I think this is the right approach.