def mystery(s):
    '''Return the position of the first number in string s. If
    there is no digit in s, return len(s).'''
    
    i = 0
    while i < len(s) and s[i] not in "0123456789":
        
    # what happens if we reverse the two conditions in the expression?    
    #while s[i] not in "0123456789" and i < len(s):
        i += 1   
    return i
    
if __name__ == "__main__":
    print mystery("abcd9fg")
    print mystery("9abc")
    print mystery("abc8def9")
    print mystery("9")
    print mystery("ab")