How to split python string every nth-1 + nth char
<p>For example, suppose we have a string:</p>

<pre><code>'abcdefg'
</code></pre>

<p>And we need to get a list like this:</p>

<pre><code>['ab', 'bc', 'cd', 'de', 'ef', 'fg']
</code></pre>

<p>we should not use any kind of library</p>

<p>Here is my solution:</p>

<pre><code>def str_split(s):
    s = iter(s)
    ch1=''
    ch2=''
    chars_list=[]
    while True:
        try:
            ch1 = ch2 or next(s)
            ch2 = next(s)
            chars_list.append(ch1 + ch2)
        except:
            break
    return chars_list
</code></pre>

<p>I wonder is there a better solution? Maybe it is possible to use list comprehension like <a href="https://stackoverflow.com/a/9475354/1845896">here</a>?</p>