import itertools
file = open('out.txt', 'w')
variations = itertools.product('abc', repeat=3)
for variations in variations:
variation_string = ""
for letter in variations:
variation_string += letter
file.write(variation_string)
file.close()
The output from the above program is like a clustered state:
aaaaabaacabaabbabcacaacbaccbaababbacbbabbbbbcbcabcbbcccaacabcaccbacbbcbcccaccbccc
Can you modify the program so that the output would be in a line after line that is the first line of the output would be aaa and the next line would be aab and the next would be aac and so on…
aaa
aab
aac
Here is a revised code that fixes a few other issues in addition to the mentioned problem: