IDLE can not open/ file directory even when the file existed on the directory.
Disk Location: C:\Users\hp\Desktop\Pythoncodes
Word text download from GitHub.
Result:
How many words shall I choose?20
Disk Location: C:\Users\hp\Desktop\Pythoncodes
Word text download from GitHub.
Result:
Output:Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
= RESTART: C:/Users/hp/Desktop/Pythoncodes/random word finder.py
>>>>>>>>>>Random Word Finder<<<<<<<<<<
Using a 466K english word text file I can pick any words at random.How many words shall I choose?20
Error:Traceback (most recent call last):
File "C:/Users/hp/Desktop/Pythoncodes/random word finder.py", line 8, in <module>
with open('C:/Users/hp/Desktop/Pythoncodes/word.text', "rt") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users/hp/Desktop/Pythoncodes/word.text'
code:import random print(">>>>>>>>>>Random Word Finder<<<<<<<<<<") print("\nUsing a 466K english word text file I can pick any words at random.\n") wds=int(input("\nHow many words shall I choose?")) with open('C:/Users/hp/Desktop/Pythoncodes/word.text', "rt") as f: words = f.readlines() words = [w.rstrip() for w in words] print("--------------------") for w in random.sample(words, wds): print (w) print("--------------------")
Larz60+ write Jul-13-2023, 09:48 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fiixed this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fiixed this time. Please use BBCode tags on future posts.