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
- Remove duplicate lines from text file
- Join list elements into string
- One-liner if else
- One-liner calculator
- How to swap two variables values
- How to get minutes from datetime
- Combine multiple txt files into one
- Check if a given string is a palindrome
- How to validate xml
- How to get hour from datetime
See more codes...