In this example we will show how to replace a string with another string using the replace() method in Python.
Source Code
my_str = 'I love Python'
print(my_str)
print(my_str.replace('I', 'We'))
Output:
I love Python
We love Python
In this example we will show how to replace a string with another string using the replace() method in Python.
my_str = 'I love Python'
print(my_str)
print(my_str.replace('I', 'We'))
Output:
I love Python
We love Python