famguy74 famguy74 - 1 year ago 71
Python Question

Counting seed values from first sequence in second sequence

If a function is given a sequence

of seed values, it needs to count for every single seed value the number of times they show up in the 2nd sequence
. Then it should return the counts as a list of integers, in the same order of the seed values. If
includes duplicated values, keep duplicated counts in the returned list. For example,
should return
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

Answer Source
def count_letter(seeds,xs):
    for c in seeds:
        for d in xs:
            if c==d:
        print (c,"Occured ",count,"times")

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download