1

I have this python code below the output of it is a text file that contain "aaaaaaaaabaaaacaaabaaaabbaaabcaaacaaaacbaaacc" I want to be able to split that to 3 letters in each line like this : aaa aaa baa

import itertools
list = (list(map("".join, itertools.product("abc", repeat=5))))
file1 = open("Wordlist.txt","w")
file1.writelines(list)

file1.close()
Faisal Rahman Avash
  • 1,268
  • 9
  • 13
Zargaf
  • 124
  • 1
  • 1
  • 11
  • can you give the link to original question ? can you please take a second look I do not think this specific question has been answered some may have similar titles. – Zargaf Oct 17 '19 at 02:55
  • The duplicate link is at the top of this page. The accepted answer should work for you. As a side note (nothing to do with your original question); don't use the variable name `list` though as it will shadow the built-in `list` function. – Selcuk Oct 17 '19 at 02:58
  • the duplicate link is about Splitting string every nth character. I want to split it and put each one in a new line. I new I kinda need a slower more simple and direct answer. – Zargaf Oct 17 '19 at 03:22
  • Well, you already got that part in your question: `file1.writelines(list)`. Your problem is being able to split the string, which that question answers. – Selcuk Oct 17 '19 at 03:28
  • that's half of the question how do I write this to a text file where it display each one in new line. – Zargaf Oct 17 '19 at 03:31
  • As I wrote above, like this: `file1.writelines(list)` – Selcuk Oct 17 '19 at 04:03

0 Answers0