Re: 3 number and dot..



On Oct 31, 10:50 pm, Roberto Bonvallet <rbonv...@xxxxxxxxx> wrote:
On 31 oct, 16:58, Abandoned <best...@xxxxxxxxx> wrote:



Hi..
I want to do this:
for examle:
12332321 ==> 12.332.321

How can i do?
x = 12332321
'.'.join(''.join(i for n, i in g) for k, g in groupby(enumerate(reversed(str(x))), lambda (n, i): n//3))[::-1]
'12.332.321'

--
Roberto Bonvallet

I'm sorry but it give me error "no module named groupby"
My python version is 2.51

.



Relevant Pages

  • Re: 3 number and dot..
    ... for examle: ... Roberto Bonvallet ... I'm sorry but it give me error "no module named groupby" My python ... Use the locale module like Chris Mellon ...
    (comp.lang.python)
  • Re: Syntax suggestion.
    ... Roberto Bonvallet wrote: ... If you want Python to look like bash, ...
    (comp.lang.python)
  • Re: More Noob Questions
    ... Roberto Bonvallet wrote: ... Python and Flash" or "Where can I find vido tutorials". ...
    (comp.lang.python)
  • Re: 3 number and dot..
    ... for examle: ... Roberto Bonvallet ... NameError: name 'groupby' is not defined ...
    (comp.lang.python)
  • Re: Conditional iteration
    ... Do you realize that Python hasn't even adopted well-known ... statements like 'switch' and 'do while' because they would be redundant? ... Roberto Bonvallet ...
    (comp.lang.python)