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
- One-liner if else
- Remove duplicate lines from text file
- Combine 2 csv files using ID column
- Combine multiple txt files into one
- One-liner calculator
- How to swap two variables values
- How to get hour from datetime
- How to validate xml
- How to get minutes from datetime
- How to check if object is of certain type
See more codes...