Program excercise : Write a function that takes two lists of strings as input, and returns a single list of unique strings common to both lists.

def common_strings(str_list1, str_list2):
    return [str_value for str_value in str_list1 if str_value in str_list2]

Another way,

def get_common_strs(list1,list2):
    return list(set(list1).intersection(set(list2)))


Comments