All pastes #509908 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-25 18:12 UTC
rendered paste body
#!/usr/bin/python

#import liste :
import sys
from random import randrange
#fin import ;


def explication() :
	print "#####################################################\n"
	print "############Jeu du Pendu by Marnage##################\n"
	print "#####################################################\n\n"
	print "python pendu.py 10 (tu pourra te tromper 10 foi )"
	print "python pendu.py 15 (tu pourra te tromper 15 foi )\n"
	print "Bon jeu ...\n"
	sys.exit()


def choisi_mot() :

	mot =["linux","debian","hacker","lamer","newbi","trouver","soldat","jour","feint","liste","livre",
"fume","wihsky","label","pirate","cheval","aigle","france","route","fraise","fruit","flash","special","prince","prive","journal","chien","source","python","video","wech","salut","shit","drogue","document","capture","janvier","disque","vodka","dingue","niveau","boire","dialogue","montage","portable","coupe"]
	
	choi_final = randrange(len(mot))
	return mot[choi_final]

def encrypt(mot_s) :
	i = 0
	bheu = 0
	liste = []
	while i < len(mot_s) :
		liste.append(bheu)
		i = i + 1
	return liste

def prop_cara() :
	op ,compteur = 0, 0
	while op != 1 :
		if compteur > 0 :
			cara = raw_input("Je tes dis de proposer UN caractere : ")
		else :
			cara = raw_input("Propose un caractere : ")
		if len(cara) > 1 :
			op = 0
			compteur = compteur + 1
		else : 
			op = 1
	print "\n"
	return cara

def verif(mot_s, cara) :
	trouve = -1
	i = 0
	while i < len(mot_s) :
		if mot_s[i] == cara :
			trouve = i
		i = i + 1
	return trouve

def gagne(mot_t) :
	i = 0
	per_ga = 1
	while i < len(mot_t) :
		if mot_t[i] == 0 :
			per_ga = 0
		i = i + 1
	return per_ga

#__main__

if len(sys.argv) < 2 :
	explication()
	


mot_secret = choisi_mot()
mot_trouv = encrypt(mot_secret)
i = 0
nbr_coup = int(sys.argv[1])
rejou = 'y'

while rejou != "n" and nbr_coup > 0 :
	gagner = 3
	print "il te reste %d chance" % (nbr_coup)
	caract = prop_cara()

	trouve = verif(mot_secret, caract)

	if trouve >= 0 :
		mot_trouv[trouve] = 1
		i = 0
		while i < len(mot_secret) :
			if mot_trouv[i] == 1 :
				print mot_secret[i],
			else :
				print '-'
			i = i + 1
	else : 
		nbr_coup = nbr_coup - 1
		if nbr_coup == 0 :
			print "perdu le mot etait : %s" % ( mot_secret )
		else :
			i = 0
			while i < len(mot_secret) :
				if mot_trouv[i] == 1 :
					print mot_secret[i],
				else :
					print '-'
				i = i + 1
	print "\n"
			
	gagner = gagne(mot_trouv)
			
	if gagner == 1 :
		print "\n--------------------------------------"
		print "-Ouai ta gagner du con ahahahahhahaah-\n"
		print "--------------------------------------"
		
		rejou = raw_input("voulez vous rejouer ? (y = oui , n = non) : ")
		if rejou == "y" :
			mot_secret = choisi_mot()
			mot_trouv = encrypt(mot_secret)
			nbr_coup = int(sys.argv[1])