How can I exclude certain tuples from being written to a file?
I found a useful program that would let me create my own wordlist based on certain characters and a chosen wordlength range. The program creates tuples and write them to a file via a for-loop.
Below is a snippet of the program.
import itertools
char = 'qwer'
output_file = 'Question4Stack.txt'
wordList = open(output_file, 'a')
for i in range(len(char), (len(char) + 1)):
for xt in itertools.product(char, repeat=i):
# xt retuns a tuple. Some of which I want to skip with continue.
wordList.write(''.join(xt) + '\n')
wordList.close()
print("\nDone Sucessfully")
I want the program to be able to skip certain tuples in which there are 3 or more of the same character present.
Outcome of snippet: (Before writing to a file)
1. ('q','q','q','q')
2. ('q','q','q','w')
3. ('q','q','q','e')
4. ('q','q','q','r')
5. ('q','q','w','q')
6. ('q','q','w','w')
7. ('q','q','w','e')
8. ('q','q','w','r')
How to skip tuple 1 - 4 in the for-loop?