Android Python string find() examples


New Member
Oct 17, 2022
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')
>>> x.find('Aloha');
Could you please help me? But I'm not convinced.
If a match isn't found it will return -1. If found it returns the starting index. Indexes start at 0 which is the beginning of the string
1. Find a substring in a string:
>>> s = "this is a string"
>>> s.find("is")

2. Find a substring in a string, starting at a given index:
>>> s.find("is", 3)

3. Find a substring in a string, using a given start and end index:
>>> s.find("is", 3, 6)
Top Bottom