Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

python substring

  • 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




This post first appeared on Java Tutorial - InstanceOfJava, please read the originial post: here

Share the post

python substring

×

Subscribe to Java Tutorial - Instanceofjava

Get updates delivered right to your inbox!

Thank you for your subscription

×