Hangman Game in Python
Hangman is a word game in which computer will randomly select a word from the dictionary and player has to guess it correctly in given number of turns. The word to be guessed is represented by row of stars. If the guessed letter is present is word, script will automatically be placed to correct places.
Rules to guess the word :
- Input single letter in one turn.
- Don’t use repeated letters.
- Turns will be decremented after every guess.
This is the text file used inside the code words.txt, which contains 50,000 English words.
Module needed :
Below is the implementation :
* * * * * Word has 5 letters Total turns: 11 Enter your guess: a Turns left 10 ********** Enter your guess: i Turns left 9 i **i**i**** Enter your guess: s Turns left 8 s **i**i**ss Enter your guess: r Turns left 7 **i**i**ss Enter your guess: h Turns left 6 **i**i**ss Enter your guess: e Turns left 5 e **i**i*ess Enter your guess: o Turns left 4 **i**i*ess Enter your guess: u Turns left 3 u *ui**i*ess Enter your guess: t Turns left 2 t *ui*ti*ess Enter your guess: n Turns left 1 n *ui*tiness Enter your guess: l Turns left 0 l *uiltiness Word is: guiltiness