Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

list - Python dict count

Problem:

Hi I'm new to Python so looking for some help. I have multiple input lines. I'm looking for a way to take every single word from multiple list and then add them up to get the total count on each instance for that word in multiple List. I will really appreciate any guidance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Edit:

"""I need a count of the word given by key(s) in multiple lists at the given index. So what I need is
>>> count(["a", "b", "c"], ["c", "b", "a"])
{"a": [1,0,1], "b": [0,2,0], "c": [1,0,1]}":
"""

I hope this will be right:

def count (*args):
    l = len(args[0])
    end = {}
    for lst in args:
        y = 0
        for x in lst:

            end.setdefault(x, l*[0])
            end[x][y] += 1
            y += 1
    return end

If you need a way to manipulate genome material from RNA/DNA you can search for libraries on pypi.python.org. There are plenty good ones.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...