[ create a new paste ] login | about

Link: http://codepad.org/FsETPAEn    [ raw code | output | fork ]

Python, pasted on Oct 14:
1
2
3
4
5
6
7
8
9
10
11
import re

def fn(n):
	s = ''
	while n!=s:
		s = n
		n = re.sub(r'^(-?\d+)(\d{3})', r'\1,\2', str(n))
	return n

print fn(1234567)
print fn(-13579)


Output:
1
2
1,234,567
-13,579


Create a new paste based on this one


Comments: