def first_alpha():
    s = input()
mn, curr = '{', '{'
i = 0
ln = len(s) if s[-1] != ' ' else len(s) - 1
while i < ln:
    if s[i] == ' ':
        if curr <= mn:
            mn = curr
ch = s[i + 1]
if 'a' <= ch <= 'z' or 'A' <= ch <= 'Z':
    curr = ch
i += 1
return mn if curr > mn else curr
Wrong output in python string loop