(Jul-03-2023, 04:21 PM)FabianPruitt Wrote: You were right it does spew out Gibberish. Is there a way to get it to spew out recognisable words in English instead?It's a task that's not so easy when talking about making recognisable words in English.
Is there any Coder on this forum that would undertake an update of this code to make it into a decent piece of software?
I would pay for the person's time of course.
There are modules like eg random-word that will generate a working random English words.
Another way is to eg use chatGPT API trough Python,seach web.
For fun can use random-word module json database and mix it with code you posted.
This just save a random word,of course adding something like
subject
will be difficult.word_length, num_words is possible to add without to much difficulty.
(Jul-03-2023, 04:21 PM)FabianPruitt Wrote: Firstly I'm not a coder and at 80 I doubt whether I will ever have enough brain cells to attempt such a task.Cool,but should start with some easier task than this.
import random import json def generate_words(word_length=4): with open('words.json') as fp: result = json.load(fp) word, _ = random.choice(list(result.items())) return word def save_words(word, folder_path): file_path = folder_path + '/generated_words.txt' with open(file_path, 'w') as file: file.write(word) print(f"Words saved successfully to '{file_path}'.") def main(): subject = input("Get a random words <Enter>: ") folder_path = input("Enter the folder path to save the file") word = generate_words() save_words(word, folder_path) if __name__ == '__main__': main()
Output:sauciness