Given two lists containing integers, the task is to find sum of frequency of element of first list in second list.

**Example: **

Input:list1 = [1, 2, 3] list2 = [2, 1, 2, 1, 3, 5, 2, 3]Output:7Explanation:No of time 1 occurring in list2 is :2 No of time 2 occurring in list2 is :3 No of time 3 occurring in list2 is :2 Sum = 2+3+2 = 7

Below are some ways to achieve the above tasks.

**Method #1:** Using `sum()`

`# Python code to find sum of frequency of ` `# element of first list in second list. ` ` ` `# List initialization ` `Input1 ` `=` `[` `1` `, ` `2` `, ` `3` `] ` `Input2 ` `=` `[` `2` `, ` `1` `, ` `2` `, ` `1` `, ` `3` `, ` `5` `, ` `2` `, ` `3` `] ` ` ` `# Using sum ` `Output ` `=` `sum` `(Input2.count(elem) ` `for` `elem ` `in` `Input1) ` ` ` `# Printing output ` `print` `(` `"Initial list are:"` `, Input1, Input2) ` `print` `(` `"Frequency is:"` `, Output) ` |

*chevron_right*

*filter_none*

**Output:**

Initial list are: [1, 2, 3] [2, 1, 2, 1, 3, 5, 2, 3] Frequency is: 7

**Method #2: Using sum() and Counter()**

`from` `collections ` `import` `Counter ` ` ` `# List initialization ` `Input1 ` `=` `[` `1` `, ` `2` `, ` `3` `] ` `Input2 ` `=` `[` `2` `, ` `1` `, ` `2` `, ` `1` `, ` `3` `, ` `5` `, ` `2` `, ` `3` `] ` ` ` ` ` `temp ` `=` `Counter(Input2) ` `Output ` `=` `sum` `(temp[x] ` `for` `x ` `in` `Input1) ` ` ` `# Printing output ` `print` `(` `"Initial list are:"` `, Input1, Input2) ` `print` `(` `"Frequency is:"` `, Output) ` |

*chevron_right*

*filter_none*

**Output:**

Initial list are: [1, 2, 3] [2, 1, 2, 1, 3, 5, 2, 3] Frequency is: 7

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- Python program to find the frequency of the elements which are common in a list of strings
- Maximum length prefix such that frequency of each character is atmost number of characters with minimum frequency
- Generate a list using given frequency list
- Python | Find frequency of given character at every position in list of lists
- Python | List frequency of elements
- Python | Sort list elements by frequency
- Python | Group list elements based on frequency
- Python | Frequency grouping of list elements
- Python - Step Frequency of elements in List
- Python - Frequency of elements from other list
- Python - Restrict Elements Frequency in List
- Python - Fractional Frequency of elements in List
- Python | Find frequency of largest element in list
- Python - Find the frequency of numbers greater than each element in a list
- Python | Sort given list by frequency and remove duplicates
- Python - Count frequency of Sublist in given list
- Python program to find the sum of the value in the dictionary where the key represents the frequency
- Python - Find frequency of given Datatype in tuple
- Python | Element with largest frequency in list
- Python | Finding frequency in list of tuples

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.