
# SearchChar  locates the leftmost occurrence of a character in a string.
# Inputs: s - the string to be searched
#         c - the character to be found
# Output:  the characters in  s  are printed one by one 
#   until  c  is encountered --- then  !  is printed.

s = raw_input("Type a string: ")
c = raw_input("Type a single char to search for: ")

count = 0
searching = True

while searching :
    # assert: have examined s[0] s[1] ..upto.. s[count-1],
    #   and none of them are  c
   
    if count == len(s) :   # A: failure?  out of letters?
        searching = False   
    elif s[count] == c :   # B: success?  found c ?
        print "!"
        searching = False 
    else :
        print s[count],
        count = count + 1

# The loop terminated because  searching==False
# This means either
# (A) count == len(s)  or
# (B) s[count] == c

# The invariant tells us
#   none of  s[0] s[1] ..upto.. s[count-1]  equals  c

# If Case (A), we conclude that
#    none of  s[0] s[1] ..upto.. s[len(s)-1]  equals  c,
# That is,  c  is not found in all of  s

# If Case (B), we conclude that
#    none of  s[0] s[1] ..upto.. s[count-1]  equals  c
#    _and_  s[count] == c
# That is, we found the _leftmost_ occurrence of c in  s

raw_input("Press Enter to finish")