Answers for "how to replace a substring in python"

1

replace substrings in python

s = 'one two one two one'
print(s.replace(' ', '-'))
# Output -
# one-two-one-two-one

s = 'one two one two one'
print(s.replace(' ', ''))
# Output -
# onetwoonetwoone
Posted by: Guest on January-03-2022

Code answers related to "how to replace a substring in python"

Python Answers by Framework

Browse Popular Code Answers by Language