Path: csiph.com!goblin1!goblin3!goblin.stu.neva.ru!news.netfront.net!not-for-mail From: "Francesco Di Matteo" Newsgroups: it.comp.lang.python Subject: Re: Contatore in funzione ricorsiva Date: Sat, 17 Oct 2015 18:22:40 +0200 Organization: Netfront http://www.netfront.net/ Lines: 36 Message-ID: References: NNTP-Posting-Host: 87.9.167.150 X-Trace: adenine.netfront.net 1445098971 23356 87.9.167.150 (17 Oct 2015 16:22:51 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Sat, 17 Oct 2015 16:22:51 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-Antivirus: avast! (VPS 151017-0, 17/10/2015), Outbound message X-Antivirus-Status: Clean Xref: csiph.com it.comp.lang.python:7599 "Antonio Valentino" 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 ---