Re: 3 number and dot..



On Oct 31, 9:58 pm, Abandoned <best...@xxxxxxxxx> wrote:
Hi..
I want to do this:
for examle:
12332321 ==> 12.332.321

How can i do?

If you want do define your own function this will work, no matter how
long the number is, or what separator you choose:

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

.