create a hangman game with python

Solutions on MaxInterview for create a hangman game with python by the best coders in the world

showing results for - "create a hangman game with python"
Greta
30 Feb 2016
1
2#importing the time module
3import time
4
5#welcoming the user
6name = raw_input("What is your name? ")
7
8print "Hello, " + name, "Time to play hangman!"
9
10print "
11"
12
13#wait for 1 second
14time.sleep(1)
15
16print "Start guessing..."
17time.sleep(0.5)
18
19#here we set the secret
20word = "secret"
21
22#creates an variable with an empty value
23guesses = ''
24
25#determine the number of turns
26turns = 10
27
28# Create a while loop
29
30#check if the turns are more than zero
31while turns > 0:         
32
33    # make a counter that starts with zero
34    failed = 0             
35
36    # for every character in secret_word    
37    for char in word:      
38
39    # see if the character is in the players guess
40        if char in guesses:    
41    
42        # print then out the character
43            print char,    
44
45        else:
46    
47        # if not found, print a dash
48            print "_",     
49       
50        # and increase the failed counter with one
51            failed += 1    
52
53    # if failed is equal to zero
54
55    # print You Won
56    if failed == 0:        
57        print "
58You won"  
59
60    # exit the script
61        break              
62
63    print
64
65    # ask the user go guess a character
66    guess = raw_input("guess a character:") 
67
68    # set the players guess to guesses
69    guesses += guess                    
70
71    # if the guess is not found in the secret word
72    if guess not in word:  
73 
74     # turns counter decreases with 1 (now 9)
75        turns -= 1        
76 
77    # print wrong
78        print "Wrong
79"    
80 
81    # how many turns are left
82        print "You have", + turns, 'more guesses' 
83 
84    # if the turns are equal to zero
85        if turns == 0:           
86    
87        # print "You Lose"
88            print "You Lose
89"  
90
queries leading to this page
hangman game using pythonwords py hangman how to make online hangman in pythonhow to make hangman in pythonhangman game in pythonhang man python 3 8hangman in python tutorialcreating a hangman game in pythonhow to write a guessing word game using the write textile in pythonhangman game on pythonpython hangmanhow do you make a hangman game using python 3fhow to make a hangman in pythonhow to draw hangman in pythonhow to make a hangman game using pythonhangman pseudocode pythonmake hangman in pythonhow to build hangman in pythonhow to make hangeman in pythonhangman python how to make hangman on pythonhangman tutorial pythonhangman project in pythoncreate hangman game in pythonhangman python game made simplehow to make a hangman game in pythonpython how to make a hangman gamewrite a hangman game in pythonpython hangman gamecreate hangman in pythonmaking a hangman game in pythonhangman word python packagebuild a hangman game in pythonhangman python code simplemake a hangman game in pythonhow to make a simple hangman game in pythonhangman python 3fhow to make hangman stickman drawing pythonfile words py hangmancoding projects python hangmanpython hangman gamemake a hangman game ini pythonhow to make hangman with pythonwords for hangman pythonpython create a hangmanhow to create hangman game in pythonhow to make a python hangman gamehangman in pythonhow to print hangman drwing in python correcthangman words pythonhow to make python hangmanpython game creator hangmanpython hangman game codebuild the hangman game using python hagman game pythonbasic python hangman gamecreate a hangman game with pythonhangman game in python codehow to import hangman in pythonhangama game in python codehow to make a hangman game on pythonsimple hangman game pythonhow to build a hangman game in pythonpython how to make hangmanwrite a hangman for pythonhangman python gamehow to make hangman game in pythonhangman in pygamethe hangman game pythoncrewate hangman in pythonhangman python tutorialmake a basic hang hangman game in pythonprogram hangman step by stephangman game with pythonhow to code hangman in pythonpython how to program hangmanhow to make a word gussing game using the read textile in pythonhangman python 3 8how to paly hangman instructions in pythonwhat is hangman game in pythoncreate a hangman game with python