def finddigit(s):
    '''
    Purpose: Find the first digit in a string s.
    Pre:  s is a string.
    Post: If s contains at least one digit, returns the index of
          the first one.  Otherwise returns -1.
    '''

    first = -1    # track the answer
    found = False # did we find the answer yet?
    index = 0     # counter to track the current index.
    for char in s:
        # 'and not found' because we only care about the first one.
        if char.isdigit() and not found:
            found = True
            first = index
        # Update the index for the next iteration.
        index += 1
    return first

def main():
    userin = input("Enter a string or type 'quit': ")
    while userin != "quit":
        pos = finddigit(userin)
        if pos >= 0:
            print("That string contains the digit", userin[pos],
                  "at position", pos)
        else:
            print("That string does not contain a digit.")
        userin = input("Enter a string or type 'quit': ")

main()
