$ Pip Install Random-Word
$ Pip Install Random-Word
I have divided this game in three parts for better coding logic. It
is always better to break the code in chunks so that it will be
easy for us to handle the logic.
Second function contains the main logic where the game decides
whether player guessed the correct word or not.
While guessing the word we can guess either letter in word or
complete word after guessing bunch of letters. So I have created
two separate conditions through which we can guess complete
word or a single letter in word. These conditions depends on the
length of the input user is giving. You will understand this
function once you go through complete source code, I have
given the link for complete source code in the end of this article.
Only important part in this function is below:
Last but not the least : Actual calling of the functions and
iteration of the game
In this part we call our earlier function start_play() to start the
game. We ask player if he/she really wants to play the game and
then game will continue until the player choose ‘N’.
Now we are all set to run the game. You can run the script by
typing following command in bash window that is “python
<scriptname.py>”