Q:

How to store parts of a string into a dictionary

For example I have 
from collections import Counter
cnt = Counter()
    text = 'CTGGAT' 
    def freqWords(text, k):
        for i in text:
            cnt [i] += 1  
        print cnt

Outputs: Counter({'A': 10, 'C': 9, 'T': 8, 'G': 4})
Which returns a nice dictionary, however, I want to store my items by the value of k. Like so, if k=2, then the dict will populate with the values of:
CT, TG, GG, GA, AT. If k=3 then: CTG, TGG, GGA, GAT. 

A:

Your for i in text iterates over the characters of text. You have to iterate over the length of text minus k and take a substring of text:
def freqWords(text, k):
    return Counter(text[i:i+k] for i in xrange(len(text) - k))

works like this:
freqWords('CTGGAT', 2)
# Counter({'GG': 1, 'TG': 1, 'GA': 1, 'CT': 1})

