writing text file with line breaks
You can use:
f.write(str(i) + '\n')
Since your lines are already in a list, you can use writelines()
:
import itertools
lista = [",".join(i)+'\n' for i in itertools.permutations('0123456789',5)]
with open('lala.txt', 'w') as f:
f.writelines(lista)
I've used the with
statement which will automatically close the file for you; and used a list comprehension to create your initial list of permutations.