Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. def find(char, string):
  2. """Return the first i such that string[i] == char
  3.  
  4. find(str, str) -> int
  5. If char does not occur in string then -1 is returned.
  6.  
  7. """
  8. i = 0
  9. length = len(string)
  10. while i < length:
  11. if char == string[i]:
  12. return i
  13. i += 1
  14. return -1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement