Python String Find operator – written tutorial with video lecture

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 to select a 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 the 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

Example:1

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”.

Output: 3
[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

Example:2

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

  • Find Operator

That is used to find the position of the specific character from a paragraph.

  • Select SubSequence

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!.

Add a Comment

Your email address will not be published. Required fields are marked *