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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -