I want to split a string of letters into a bunch of triplets and assign numbers to each triplet and then find the sum of the numbers. I managed to code till the number assigning part. But not able to generate the sum.Lot of errors popping up. Please help. P.S. I am a biologist and know nothing about coding. This is my partial code:
gene_code = "abcdef"
split_strings = []
n = 3
for index in range(0, len(gene_code), n):
split_strings.append(gene_code[index : index + n])
print(split_strings)
import re
gene_code = gene_code.replace('abc','1.2,')
gene_code = gene_code.replace('def','2.3,')
print(gene_code)
the output is as follows
['abc', 'def']
1.2,2.3,
Now I want to get the sum of these numbers. Please help?