pythonUsing string replace()
yourString.replace(oldvalue, newvalue, count)ctrl + c.replace(replaces specific phrase with other specified phrase (does not require any imports) |
Usage example
sentence = "I like Apple"
y = sentence.replace("Apple","Pear")
print(y)
output
I like PearMore of Python
- How to swap two variables values
- One-liner calculator
- One-liner if else
- How to merge two lists
- How to order dict by keys
- How to get hour from datetime
- How to use proxy
- How to sleep for specific number of seconds
- How to check if object is of certain type
- How to get yesterday's date
See more codes...