I have a set that contains all the possible values present in a list. What I want is to know how much of each value are present in the list.
So, I have:
set_a = ("a","b", "c", "d")
lst = ["a", "b", "c", "c"]
What I want is this:
a 1
b 1
c 2
I have a set that contains all the possible values present in a list. What I want is to know how much of each value are present in the list.
So, I have:
set_a = ("a","b", "c", "d")
lst = ["a", "b", "c", "c"]
What I want is this:
a 1
b 1
c 2
You will see solutions here: How can I count the occurrences of a list item in Python?
For instance you can do:
[1, 2, 3, 4, 1, 4, 1].count(1)