find substring():

  • The find substring is used to find the substring from the string.
  • Substring is the piece of characters from the string.
  • If the string consists of the given string then it returns the index number of the substring. 
  • The string must be enclosed with single or double-quotes.
  • It returns -1 if the substring does not found instead of an error.
  • find() has 3 parameters,they are:
  1. value: The value to be search
  2. start:  from where to search
  3. end:  from where to stop searching.
Syntax: str.find(value,start,end)

#write a python code to demonstrate the find substring function.

  1. txt="learning is a life time process"
  2. txt=txt.find("i")
  3. print(txt)
  4. s="apple"
  5. s=s.find("b")
  6. print(s)

Output: 5
              -1







Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu