How to Replace Dot with Space String in Python?

25-Mar-2023

.

Admin

How to Replace Dot with Space String in Python?

Hi Dev,

This tutorial will provide an example of how to replace a dot with a space string in python. I would like to show you python replace dot with space. This article goes in detail on python string replace dot with space. this example will help you how to replace a dot with space in python.

In this example, I will add myString variable with the hello string. Then we will use replace() function to replace the dot with a space in the python string. So, without further ado, let's see simple examples: You can use these examples with the python3 (Python 3) version.

Example


main.py

myString = 'nicesnippets.com'

# python string replace dot with space

newString = myString.replace('.', ' ')

print(newString)

Output:

nicesnippets com

#Python