- 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.
- start: It 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.
- s="hello every one"
- print(s[:])
- print(s[:5])
- print("h" in s)
- s=s*3
- print(s)
output: hello every one
hello
true
hello every one hello every one hello every one.
No comments