I need to know how to format a single strand of DNA in one line of code into a given width so it reads as multiple lines. What I am trying to do is insert a newline character at a given width. This is my code thus far:
def formatSeq(dna, width): #dna strand and given width passed to fucntion
seq =[]
start =0
while start < len(dna):
if start + width < len(dna):
seq = seq + dna[start:start+width]]
start = start + width
else:
seq += dna[start:]
seq.append('\n')
return seq
When executed the program does not terminate and the output file is blank.