#-*- coding:latin-1 -*- import Tkinter mot_a_trouve = "pendu" nb_coup = 0 # dessin de la fenêtre root = Tkinter.Tk () coup = Tkinter.Label () coup.pack () jeu = Tkinter.Label () jeu.pack () lettre = Tkinter.Entry () lettre.pack () b = Tkinter.Button (text = "jouer") b.pack () # fonction pour le pendu def blanc_souligne (mot, lettres) : res = "" for m in mot : if m in lettres : res += m else : res += "_" return res def fonction_jouer () : global mot_a_trouve global nb_coup global coup global jeu global lettre nb_coup += 1 m = blanc_souligne (mot_a_trouve, lettre.get ()) if "_" in m : coup.config (text = "nombre de coups " + str (nb_coup)) else : coup.config (text = "gagné") jeu.config (text = m) b.config (command = fonction_jouer) # root root.mainloop ()