• In python, we have the string concept from that we have a small topic called substring.
  • "substring " is the string that is a part of the main string.
  • In other words, we can say that extraction of the characters from the string.
  • We can access the string by using the index and substring by using the concept of slicing.
  • For the creation of the list of substrings, we use the split().
  • It follows string[start:end: step] in slicing concept by this the substring is formed.
  • startIt is the starting index of the substring. By default, it is 0.
  • end: It is the ending index of the substring. By default, it is the length of the string.
  • step: It is used to increment the index by the given numbers.
  • We use some of the functions in the substrings.
  • In operator: It is used to find the substring that is present in the string.
  • Count(): It is used to count the number of times the substring occurred in the string.It is denoted by the "*" symbol.

#Write a python program to find the substring from a string.

  1. s="hello every one"
  2. print(s[:])
  3. print(s[:5])
  4. print("h" in s)
  5. s=s*3
  6. print(s)

output: hello every one
             hello
              true
              hello every one hello every one hello every one.


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