Find & Replace Method In python | Python replace() & Find () in Hindi

Find & Replace Method In python :- Python Replace () And Find () Function kyo important hai or iska kyo istemal hota hai.

Find() Method in python ko ham kisi bhi number ya character ko find karne ke liye istemal karte hai.

Replace() method in python ko ham kisi bhi number ya character ko replace karne ke liye istemal karte hai.Python replace() & Find ()

Python replace() & Find ()

Python String replace() & Find ()
Find & Replace Method In python

Replace () Function

Syntax

string.replace(old, new, count)

Example :-

string = "Master Programing "

# Prints the string by replacing Master by master 
print(string.replace("Master", "master")) 

# Prints the string by replacing only 2 occurence of Programing 
print(string.replace("Programing", "programing", 2)) 

Output :-

master
programing programing

Find() Method in python

Find() Function in python

Syntax

string.find(sub,start,end)

Example :-

website = 'master programing'
 
strfind = website.find('master') 
print ("Sub string 'master' found at index:", strfind ) 

result = website.find('programing') 
print ("Sub string 'programing ' found at index:", result ) 

Output :-

Sub string 'master' found at index:0
Sub string 'programing ' found at index:7

Find & Replace Method In python

Danish Ali

I Am a Cyber Security Student & I have Skills C, C++ ,Python, HTML,CSS, Computer & Advance Hacking & Blogger & YouTuber.

Leave a Reply

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

Show Buttons
Hide Buttons