#------------------------------------------------------------------------------ # FindInString.py #------------------------------------------------------------------------------ def find(s, ch): """ Find and return the index of ch in string s. Return None 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 # if execution reaches here, returns None # end find() # function main() ------------------------------------------------------------- def main(): t = 'Hello, World!' print( find(t, 'W') ) print( find(t, 'q') ) # end main() # closing conditional --------------------------------------------------------- if __name__=='__main__': main() # end