Dec-05-2021, 09:01 PM
i have a somewhat simple question, that seems to be escaping me. i was messing around with the built-in method itertools to see if i could get anagrams of my name, anyway.. i wanted to write the results out to a file but i only get oneline written out. i tried writelines , i tried moving the with open()
method outside of my for loop but i seem to missing something else.
edit:
i made a edit or two because i had two scripts and i wasnt sure which i copied and pasted , this has the string2 variable from where i was comparing to another for loop, but no big deal still the same issue.
method outside of my for loop but i seem to missing something else.
edit:
i made a edit or two because i had two scripts and i wasnt sure which i copied and pasted , this has the string2 variable from where i was comparing to another for loop, but no big deal still the same issue.
from itertools import permutations string2 = 'derp' list1 = [] for i in permutations(string2): new = ''.join(i) print(new) with open('file1.txt','w') as f: f.writelines(new)