How do I find the max integer of a string of integer without using a list?
<p>I must use a for loop, no list allowed. May assume string is non-empty. What I have:</p>

<pre><code>def max_numbers(s):
    n_string = ''
    for char in s:
        if char.isdigit():
            n_string += char
    return max(n_string)

max_numbers('22  53 123 54 243')
5
expected 243
</code></pre>

<p>Please don't use any advance methods, I am still a beginner. I wanted 243 to show up but ended up with 5 instead.</p>

<pre><code>def max_numbers(s):
    # biggest number we've seen so far.  init to a very small number so
    # it will get replaced immediately by real input data
    biggest = -999

    # accumulate digit characters from input
    n_string = ''

    # loop through each input character
    for char in s:

        # is it a digit 0-9?
        if char.isdigit():

            # add it onto the end of n_string
            n_string += char

        # not a digit
        else:

           # if n_string has some digits in it
           if n_string:

                # calculate integer value of n_string, and if it's bigger
                # than the previous biggest, save it as the new biggest
                biggest = max(biggest, int(n_string))

                # reset n_string back to empty
                n_string = ''

    return biggest
</code></pre>

python