origCodon = ([orig[i: i + groupSize] for i in range(len(orig) + 1 - groupSize)])
patCodon = ([pat[i: i + groupSize] for i in range(len(pat) + 1 - groupSize)])
print (patCodon)
origCode = []
patCode = []
for p in patCodon:
for d in dna:
if d == p:
x = dna[p]
print (p)
patCode.append(x)
The code above takes two lists and splits them into groups of three, but when I go to check each individual element, it makes a new list of three, moving along one element each time.
i.e. this is one list made:
['AAC', 'ACT', 'CTG', 'TGC', 'GCA', 'CAG', 'AGC', 'GCT', 'CTC', 'TCA']
But these are the elements it checks:
AAC
ACT
CTG
TGC
GCA
CAG
AGC
GCT
CTC
TCA
How do I make it so that each group of three is checked and then it moves on to the next?
My list is split into groups of three (becoming items in the list), I want to check each of those items for their corresponding amino acid (in a dictionary), but the program keeps making new lists, e.g. the user enters AAATTT, then the program checks:
AAA
AAT
ATT
TTT
rather than just AAA and TTT