How to identify ordered substrings in string using python?
<p>I am new to python, so my question would be naive but I would appreciate your suggestion that help me get to the solution of it.</p>

<p>For example I have string "aeshfytifghkjgiomntrop" and I want to find ordered substrings from it. How should I approach?</p>

<p>Scan the string using <code>enumerate</code> to issue index and value.
Print string parts when chars are decreasing and start a new substring:</p>

<pre><code>s = "aeshfytifghkjgiomntrop"

prev_c = None
prev_i = 0

for i,c in enumerate(s):
    if prev_c&gt;c:
        print(s[prev_i:i])
        prev_i=i
    prev_c=c
print(s[prev_i:])
</code></pre>

<p>result:</p>

<pre><code>aes
h
fy
t
i
fghk
j
gio
mnt
r
op
</code></pre>

<p>(No particular Python magic here, could be done simply even with C)</p>

python string