Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ed8c68

Browse files
committed
Add a note to the str.find doc to suggest the use of the "in" operator.
1 parent 262c582 commit 0ed8c68

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Doc/library/stdtypes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,15 @@ functions based on regular expressions.
883883
*start* and *end* are interpreted as in slice notation. Return ``-1`` if
884884
*sub* is not found.
885885

886+
.. note::
887+
888+
The :meth:`~str.find` method should be used only if you need to know the
889+
position of *sub*. To check if *sub* is a substring or not, use the
890+
:keyword:`in` operator::
891+
892+
>>> 'Py' in 'Python'
893+
True
894+
886895

887896
.. method:: str.format(*args, **kwargs)
888897

0 commit comments

Comments
 (0)