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
- Check if a given string is a palindrome
- How to get minutes from datetime
- How to add an element to the list
- How to check if object is of certain type
- One-liner if else
- Join list elements into string
- How to swap two variables values
- One-liner calculator
- Remove duplicate lines from text file
- How to get hour from datetime
See more codes...