Jul-03-2023, 02:19 PM
Firstly I'm not a coder and at 80 I doubt whether I will ever have enough brain cells to attempt such a task.
But I do enjoy making Wordsearch Puzzle books. It keeps the little brain cells from going completely dead. The reason I'm here is that ChatGPT gave me a Python code
SyntaxError: invalid syntax
Word Generator.py line 1
But there's nothing on line 1, so can anyone tell me what's gone wrong, please remember that I have hardly any knowledge about coding.
Thanks a lot
But I do enjoy making Wordsearch Puzzle books. It keeps the little brain cells from going completely dead. The reason I'm here is that ChatGPT gave me a Python code
```python import random def generate_words(subject, word_length, num_words): words = [] letters = 'abcdefghijklmnopqrstuvwxyz' for _ in range(num_words): word = ''.join(random.choice(letters) for _ in range(word_length)) words.append(subject + word) return words def save_words(words, folder_path): file_path = folder_path + '/generated_words.txt' with open(file_path, 'w') as file: for word in words: file.write(word + '\n') print(f"Words saved successfully to '{file_path}'.") def main(): subject = input("Enter the subject of the words: ") word_length = int(input("Enter the number of characters per word: ")) num_words = int(input("Enter the number of words to generate: ")) folder_path = input("Enter the folder path to save the file (e.g., C:/Users/Username/Desktop/WordGenerator): ") words = generate_words(subject, word_length, num_words) save_words(words, folder_path) if __name__ == '__main__': main() ```for a Word Generator that I could run on Windows but there is something wrong with the code. I ran it in Thonny and it gave this.....
SyntaxError: invalid syntax
Word Generator.py line 1
But there's nothing on line 1, so can anyone tell me what's gone wrong, please remember that I have hardly any knowledge about coding.
Thanks a lot