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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -