Module 12
Dictionaries and sequences
Counting with dictionaries.
Counting with dicts
Dictionaries are perfect for counting. Each key is a pattern, each value is the count.
seq = "AATTGGCC"
counts = {}
for base in seq:
counts[base] = counts.get(base, 0) + 1
print(counts)Your task
Count with dict
- Count each base in AATTGGCC using a dictionary.