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>

<p>If @IvanCai's answer is too advanced try:</p>

<pre><code>def max_numbers(s):
    top=0
    curr=0
    for char in s:
        if char.isdigit():
            curr*=10
            curr+=int(char)
            if curr&gt;top:
                top=curr
        elif char==' ' or char=='\n':
            curr=0
    return top
print(max_numbers('22 53 123 54 243'))
</code></pre>

python