-1

I have this string

s = '4294967296'

I want to split this into

4.294.967.296

Basically I want to insert a dot every 3rd digit. How can I do this? I tried

c = '4294967296'

for x,y in enumerate(c[::-1]):
    if x % 2 == 0:
        b = c[:x] + '.' + c[:x]
print (b)

But the output was

>>> 
42949672.42949672
>>>
GLHF
  • 3,835
  • 10
  • 38
  • 83

1 Answers1

2

You can (ab)use string formatting:

s = '4294967296'
t = format(int(s), ',').replace(',', '.')
# '4.294.967.296'
Jon Clements
  • 138,671
  • 33
  • 247
  • 280