import random def main(): print('Creating data...') # Create JSON data # Create JSON data WordList = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q'] ValidWordList = ['r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] file = open('data.json', 'w') file2 = open('validData.json', 'w') for k in range(10000): file.write('{"translation":{"let":') if k <= 1000: file2.write('{"translation":{"let":') randomNum = random.randint(1, 50) word = [] word2 = [] for i in random.sample(range(1, 100), randomNum): word.append(WordList[i%17]) if k <= 100: word2.append(ValidWordList[i%9]) wordStr = ''.join(word) wordRev = wordStr[::-1] if k <= 1000: wordStr2 = ''.join(word2) wordRev2 = wordStr2[::-1] file2.write(f'"{wordStr2}", "rev" :"{wordRev2}"') file2.write('}}\n') file.write(f'"{wordStr}", "rev" :"{wordRev}"') file.write('}}\n') file.close() file2.close() if __name__ == '__main__': main()