-2

I know .find() can search for a specific character, but I need something that can return a boolean instead of the exact location of the the character.

bastelflp
  • 9,362
  • 7
  • 32
  • 67
  • 2
    Do you mean like `in`, e.g. `'y' in 'xyz'` returns `True`? – Alex Riley Jul 28 '15 at 20:42
  • you could write one yourself . Shouldnt take more than 3-4 lines of code – letsc Jul 28 '15 at 20:43
  • A Google search of "python 3 check if character is in string" returns numerous hits, each of which answers your question in seconds. Did you even *try* to search for the answer before posting? – John Coleman Jul 28 '15 at 20:46
  • 1
    possible duplicate of [Does Python have a string contains method?](http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-method) – Ray Jul 29 '15 at 20:18

1 Answers1

0

Use the "in" operator.

> a = 'now is the time...'  
> b = 'time'  
> exists = a in b  
Rick O'Shea
  • 1,410
  • 19
  • 15