from random import * def afficher(n): print "Il reste {0} allumettes :".format(N) print "|"*N N = randint(12,48) afficher(N) while N > 0: R = 0 while R not in [1,2,3]: R = int(raw_input("Choisis un nombre d'allumettes entre 1 et 3 :")) N -= R afficher(N) if N <= 0: print "Bravo c'est toi qui gagnes !!!" break else: R = min(N,randint(1,3)) print "Je prends {0} allumette(s) :".format(R), "|"*R N -= R afficher(N) if N <=0: print "C'est moi qui gagne !" break