#------------------------------------------------------------------------------ # FindInString.py #------------------------------------------------------------------------------ def find(s, ch): """ Find and return the index of ch in string s. Return -1 if ch does not occur in string s. """ i = 0 while i < len(s): if s[i] == ch: return i # end if i += 1 # end while return -1 # end find() #-- main program -------------------------------------------------------------- t = 'Hello, World!' print( find(t, 'W') ) print( find(t, 'q') )