Answers for "replace function"

1

replace function

#replace(a,b) is the function which can replace the 'abc' word to 'klmn' word
example
a=input(' sentence :')
b=input(' word to be replaced :')
c=input(' word to be replaced with :')
d=a.replace(b,c)
print(d)
#output:
'''
sentence :richard play with pixis and natasha, rahim play along johan,rosel and ethan 
word to be replaced :play
word to be replaced with :go
richard go with pixis and natasha, rahim go along johan,rosel and ethan 
'''
Posted by: Guest on January-20-2022
0

string replace

string = "Hey! What's up?"
characters = "'!?"

for x in range(len(characters)):
    string = string.replace(characters[x],"")

print(string)
Posted by: Guest on December-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language