string[i:j:k]

alex23 wuwei23 at gmail.com
Tue Jul 22 01:18:37 EDT 2008


On Jul 22, 3:10 pm, konstantin <konstantin.seliva... at gmail.com> wrote:
> some_string[i:j:k]
> What does it mean?

i = start position, j = end position, k = step size

>>> s = "ABABABABABABAB"
>>> s[0:6:2]
'AAA'
>>> s = "ABCABCABCABCABC"
>>> s[0:6:3]
'AA'

Hope this helps.

- alex23



More information about the Python-list mailing list