Python string find() examples

Sachinbhatt

Mitglied
I'm looking for examples but am having no luck.
Is anyone aware of any examples on the internet? I'd like to know what it returns when it can't find something, and how to specify from start to end, which I assume will be 0, -1.
Python:
>>> x = "Hello World"
>>> x.find('World')
6
>>> x.find('Aloha');
-1
Could someone please assist me? But I'm not sure about it.
 
Are you looking for a reference? That could be found at:

So find takes the arguments:
  • String to search for
  • Optional: start
  • Optional: end
and it returns the index where the text is found or -1 if it cannot find the string you are looking for.
 

Zurück
Oben