0

So what I want to do is save the output of this program into a text file.

import itertools
res = itertools.product('qwertyuiopasdfghjklzxcvbnm', repeat=3)
for i in res: 
print ''.join(i)

Im running python 2.7

1 Answer 1

1

You can use open and then write method of the resulting file handler.

import itertools
res = itertools.product('qwertyuiopasdfghjklzxcvbnm', repeat=3)

with open('output.txt', 'w') as f:
    for group in res:
        word = ''.join(group)
        f.write(word+'\n')
        print(word)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.