If a function is given a sequence seeds
of seed values, it needs to count for every single seed value the number of times they show up in the 2nd sequence xs
. Then it should return the counts as a list of integers, in the same order of the seed values. If seeds
includes duplicated values, keep duplicated counts in the returned list. For example, count_each([10,20],[10,20,50,20,40,20])
should return [1,3]
and count_each('aeiou','encyclopedia') should return [1,2,1,1,0]
.
I'm stuck on how to program this function. This is what I have so far but I can't figure out how exactly I would count the number of seed values in the second sequence and not just check if the values exist. Any help on this would be appreciated.
def count_each(seeds,xs):
if seeds in xs:
if seeds == True
return seeds
elif seeds == False
return None