slice - Slicing in Python(Not Duplicate, Slicing for Translation) -


this question has answer here:

hey guys have simple question.

how slice string of length equal parts

ie agttgtcgaggttgcgatttattgggtgcgagt 3 into

agt tgt cga ggt tgc gat tta ttg ggt gcg agt

?

>>> s = 'agttgtcgaggttgcgatttattgggtgcgagt' >>> n = 3 >>> [s[i:i+n] in xrange(0, len(s), n)] ['agt', 'tgt', 'cga', 'ggt', 'tgc', 'gat', 'tta', 'ttg', 'ggt', 'gcg', 'agt'] 

Comments

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -