Add a character in between a string
How can I add a comma after every three characters in a string? For example, i have a string number = "2000"
, and the program should add a comma to the string after three places from the right. How can this be done?
I've tried this, but to no avail.
integer = 2000
print(str(integer)[:3] + "," + str(integer)[3:])
When i run this, it prints out 200,0