Python String Find Operator
In this lecture, we are going to learn â€œfind the position of the character in a string through Python String Find Operatorâ€. In the Previous lecture, we learn select subsequence from a string by of it index that starts from 0. Now, we are going to learn how to find the index of a specific character.
Now can find the position (index) of a specific character from the string. We can use Find operator to find the position of a specific character. Â Find operator is a possessor that is provided by Python to find the position.
Syntax of Find Operator
Syntax: Â Â print(name_variable.find (“name_of_character”))
Let we take an example
name = "friend"Â Â Â Â Â Â Â Â Â # now, find position of e in the following string
print (name.find("e"))Â # find operator is used to find the position of â€œeâ€.
[mks_pullquote align=”left” width=”620″ size=”15″ bg_color=”#a7d695″ txt_color=”#353535″]Note:
the character of the string will be written between in Double quotation(” “) or you can also be used single quotation (‘ ‘). Dot operator(.) is used to concatenate Find Operator
with the variable name.[/mks_pullquote]
How to print some line of Paragraph?
Print some Line of Paragraph by using Find Operator and Selecting Sub Sequence Article. Itâ€™s a combination of both concepts that discussed in the previous two lecture. Let we take an example
It is a dummy paragraph that is given below in the following example. We want to print full paragraph tell end after first â€œ i â€ keyword.Â First,Â we use Find operator to find the position of character then use select subsequence.
para = " My name is ABDUL JABBARÂ and I am Student of MS Computer Science "Â Â Â
seq = (para.find(" i "))Â Â Â Â Â Â Â Â Â Â #this is used to find position of â€œ i â€ character
print ( para [ seq:Â ] )
Output: Â is ABDUL JABBARÂ and I am Student of MS Computer Science
Two methods are used to print some specific line of Paragraph
That is used to find the position of the specific character from a paragraph.
It used to print the following statements of Paragraph with the help of Find Operator.
I hope this article is very helpful to learn about the â€œPython String Find Operator â€. This is a complete series of Python3. You can also learn about HTML5 and PHP7 and many other languages. If you have any question, then you will be discussed in the comments section. Please also give your feedback about this article. Thank You!.