Dorthy
(Dorthy Maiden)
October 17, 2022, 11:59am
1
I’m looking for examples, but I’m not finding any.
Are there any examples on the internet? I’d like to know what it returns when it can’t find something, as well as how to specify the starting and ending points, which I assume will be 0, -1.
>>> x = "Hello World"
>>> x.find('World')
6
>>> x.find('Aloha');
-1
Could you please help me? But I’m not convinced.
Mholscher
(Menno Hölscher)
October 17, 2022, 12:09pm
2
From the Python documentation: If you look for substring sub in a string:
Return -1
if sub is not found.
This can be found at:
The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some colle...
That also specifies how to use the start and stop parameters to limit your search.
The documentation is generally very good and will answer most if not all of this type of queries.
3 Likes