Get matched list quickly in python
If you do not consider the list order, it is better to use set
and &
operator.
a = [1, 2, 3] b = [2, 3, 4] c = sorted(list(set(a) & set(b)))
If you do not consider the list order, it is better to use set
and &
operator.
a = [1, 2, 3] b = [2, 3, 4] c = sorted(list(set(a) & set(b)))