Itertools Python3

Smith smith at smith.com
Tue Aug 30 08:38:59 EDT 2016


Il 30/08/2016 12:28, Chris Angelico ha scritto:
> On Tue, Aug 30, 2016 at 8:24 PM, Smith <smith at smith.com> wrote:
>> I can not write to the file.
>> Can someone help me?
>> Thanks
>>
>> from itertools import product
>> valore = input('Inserisci un valore:  ')
>> risultato = product(valore, repeat = 3)
>> with open("file.txt", "w") as result:
>>         for i in risultato:
>>                 print (result,"".join(i))
>
> Do you get an exception, possibly from the product() call? When you
> ask for help, copy and paste the entire traceback and error message;
> it's extremely useful information.
>
> I'm pretty sure I know what the problem is here, but I want you to
> post the traceback, so that you learn how debugging of Python code
> works :)
>
> ChrisA
>
The problem is solved
I thank you for your time

from itertools import product
valore = input('Inserisci un valore:  ')
risultato = product(valore, repeat = 3)
with open("file.txt", "w") as result:
         for i in risultato:
                 print  ("".join(i),file=result)



More information about the Python-list mailing list