It’s been a long time since i’ve done a blog post. I wonder why….

Welp, today I’ve got an assignment, today’s one is to write a python program that prints a version of the strings with all commas replaced by dots. Like this.

Example -

  Input               Output
"Hello, World!"      "Hello. World!"
"725,000"            "725.000"

First, I’m going to do the 1st one. I’m going to assign it to a variable called string.

string = 'Hello, World!'

Then I’m going to use the print and replace function.

print(string.replace(',', '.'))

Now the comma would be replaced by dots.

Final -

string = 'Hello, World!'
print(string.replace(',', '.'))

The same thing goes with the ‘725,000’

string = '725,000'
print(string.replace(',', '.'))

And there you go.

Bye bye! =D