jeu du pendu : téléchargement et filtrage du dico

This commit is contained in:
nojhan 2012-03-19 00:14:41 +01:00
commit 512c6269e7
3 changed files with 124525 additions and 0 deletions

62250
data/french_dictionary.latin1 Normal file

File diff suppressed because it is too large Load diff

62250
data/french_dictionary.utf8 Normal file

File diff suppressed because it is too large Load diff

25
src/pendu.py Normal file
View file

@ -0,0 +1,25 @@
#encoding: utf-8
import random
from urllib.request import urlopen
def download_dic( url ):
with urlopen( url ) as page:
return page.read().split()
def filter_wordsize( words, word_size = 3 ):
return [w for w in words if len(w) == word_size ]
def pick_word( words ):
return words[ random.randrange( len(words) ) ]
if __name__=="__main__":
word_size = 5
words = filter_wordsize( download_dic( "http://nojhan.net/aapssfc/data/french_dictionary.utf8" ), word_size )
print(len(words),"mots dans le dictionaire")
secret_word = pick_word( words )