def get_counts(sequence):
counts={}
for x in sequence:
if x in counts:
counts[x] += 1
else:
counts[x] = 1
return counts
aa=['a','b','c','d','a','g']
print get_counts(aa)
C:Python27python.exe C:/Users/TLCB/PycharmProjects/untitled/analyze/a6.py
{'a': 2, 'c': 1, 'b': 1, 'd': 1, 'g': 1}