On Oct 31, 9:58 pm, Abandoned <[EMAIL PROTECTED]> wrote: > Hi.. > I want to do this: > for examle: > 12332321 ==> 12.332.321 > > How can i do?
Hi, If you want to define your own function, no matter what the length of the number is or what separator you want to choose, this will work: def conv(s, sep='.'): start=len(s)%3 last=start result=s[0:start] for i in range(start+1,len(s)): if (i-start)%3==0: if last==0: result+=s[last:i] else: result+=sep+(s[last:i]) last=i if last==len(s) or last==0: result+=s[last:len(s)] else: result+=sep+s[last:len(s)] return result print conv('1234567890000000') print conv('1') print conv('123') print conv('1234') >>> 1.234.567.890.000.000 1 123 1.234 -- http://mail.python.org/mailman/listinfo/python-list