In case you could need to get random words for a game or anything else, you could use this code:
''' get 4 random words '''
from urllib.request import Request, urlopen
import random
url="https://svnweb.freebsd.org/csrg/share/dict/words?revision=61569&view=co"
# request object pointing at the url
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
# all the words in bytes
web_byte = urlopen(req).read()
# decoding into a string with all words
webpage = web_byte.decode('utf-8')
# create a list
wdslst = webpage.splitlines()
fourwords = random.sample(wdslst, 4)
print(fourwords)
Subscribe to the newsletter for updates
Tkinter templatesTwitter: @pythonprogrammi - python_pygame
Claude's Games
1. Memory gameVideos
Speech recognition gamePygame's Platform Game