Answers for "which method can be used to replace parts of a string in python"

3

python replace

string = "[Message]"
string = string.replace("[", "")#Removes all [
string = string.replace("]", "")#Removes all ]

print(string)
Posted by: Guest on September-28-2020
1

python replace

temp_str = 'this is a test'
print(temp_str.replace('is','IS')
print(temp_str)
      
#################### Result ###########################
      
thIS IS a test
this is a test
Posted by: Guest on July-02-2021
0

set replace python

# Replace 1 with 4
s = {1, 2, 3}
s.remove(1)
s.add(4)
Posted by: Guest on July-22-2020

Code answers related to "which method can be used to replace parts of a string in python"

Python Answers by Framework

Browse Popular Code Answers by Language