0

I am writing code that should iterate through a string and print the next three characters. I got it to step 3 characters and display it. The issue is that instead of displaying the next three characters it displays the next three characters AND the previous characters. How can I change the code so that it only prints out the next three characters every time it iterates? For instance, the first iteration will print "ACG" and the second iteration should print "TAC", not "ACGTAC".

sequence = "ACGTACTACGCTATATCGATCATGCTATGCGATTATCAGAGCGAGCGACGATCTACGACTGATCGTAAGA"
seq = []
for i in range(0,len(sequence),3):
    seq = sequence[:i]
    print(seq) 

0 Answers0