• # Le programme qui va bien

    Posté par . En réponse au journal apprendre par coeur. Évalué à 3.

    Le voilà, plus qu'à saisir du vocabulaire dans lstLoc, l'appeler truc.py et le lancer:

    -----------8<-----------------------------
    # -*- coding: Utf-8 -*-
    from random import randint
    import sys, locale
    class Voc:
    def __init__(self,lstVoc):
    self.lstVoc = lstVoc

    def ask(self):
    indice = randint(0,len(lstVoc)-1)
    print lstVoc[indice][0],"->"
    text = sys.stdin.readline()
    if (text[:-1] == lstVoc[indice][1]):
    print "Bravoooo..."
    else:
    print "Faux."


    loc = locale.getdefaultlocale()
    reload(sys)
    sys.setdefaultencoding(loc[1])

    lstVoc=(
    (u"The",u"Le"),
    (u"Tea",u"Thé"))
    voc = Voc(lstVoc)
    while (True):
    voc.ask()