Python-Indexing- I do not understand how this bit of code is working
<p>What I do not understand is how indexing a string s = "azcbobobegghakl" would correctly give me the answer 'beggh' if I was looking for the longest substring in alphabetical order. How does this code tell the computer that 'beggh' is in alphabetical order? I thought indexing just gave each letter in the string a number that increased by one until the string ended? I tweaked the code a bit and it worked, but I do not actually understand how the code works in the first place.   </p>

<pre><code>s = "azcbobobegghakl"
longest = s[0]
current = s[0]
for c in s[1:]:
    if c &gt;= current[-1]:
        current += c
    else:
        if len(current) &gt; len(longest):
            longest = current
        current = c
print "Longest substring in alphabetical order is:", longest
</code></pre>

<pre><code>s = "azcbobobegghakl"

# initialize vars to first letter in string
longest = s[0]
current = s[0]

# start iterating through rest of string
for c in s[1:]:

    # c is the letter of current iteration and current[-1]
    # is the last letter of the current string. Every character 
    # has an ASCII value so this is checking the character's 
    # numerical values to see if they are in alphabetical order (a&lt;b&lt;c etc.)
    if c &gt;= current[-1]:

        # so if c is bigger than current[-1] (meaning it comes
        # after in the alphabet, then we want to add it to current
        current += c
    else:
        # if c was smaller then we want to check if the alphabetic
        # string we just read is longer than the previous longest
        if len(current) &gt; len(longest):
            longest = current

        # start the current string over beginning with the letter in c
        current = c
print "Longest substring in alphabetical order is:", longest
</code></pre>

python python-3.x