Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.python > #7599

Re: Contatore in funzione ricorsiva

From "Francesco Di Matteo" <frankdimat@TEMPOlibero.it>
Newsgroups it.comp.lang.python
Subject Re: Contatore in funzione ricorsiva
Date 2015-10-17 18:22 +0200
Organization Netfront http://www.netfront.net/
Message-ID <mvtskr$mps$1@adenine.netfront.net> (permalink)
References <mvtcdh$csn$1@adenine.netfront.net> <mvtp46$khq$1@adenine.netfront.net>

Show all headers | View raw


"Antonio Valentino" <antonio.valentino@tiscali.it> ha scritto nel messaggio 
news:mvtp46$khq$1@adenine.netfront.net...
> Ciao Francesco,
>
[cut]
>
>
> esiste una funzione della libreria standard per generare le
> permutazioni: itertools.permutations.
>
> Per enumerare un iterabile si usa solitamente la funzione "enumerate".
>
> In sintesi:
>
>
> import itertools
>
> for n, i in enumerate(itertools.permutations([1, 2, 3])):
>    print('{} {}'.format(n, i))
>
>
> dovrebbe fare quello che chiedi.
>
> In forma più sintetica puoi usare anche:
>
> print('\n'.join('{} {}'.format(n, i) for n, i in
> enumerate(itertools.permutations([1, 2, 3]))))
>
>

grazie davvero 



--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to it.comp.lang.python | Previous | NextPrevious in thread | Find similar


Thread

Contatore in funzione ricorsiva "Francesco Di Matteo" <frankdimat@TEMPOlibero.it> - 2015-10-17 13:45 +0200
  Re: Contatore in funzione ricorsiva Leonardo Serni <lserni@gmail.com> - 2015-10-17 15:10 +0200
  Re: Contatore in funzione ricorsiva Antonio Valentino <antonio.valentino@tiscali.it> - 2015-10-17 17:22 +0200
    Re: Contatore in funzione ricorsiva "Francesco Di Matteo" <frankdimat@TEMPOlibero.it> - 2015-10-17 18:22 +0200

csiph-web