We can think of the current hangman code as consisting of 3 different parts:
A part that randomly selects the target word to be guessed
A part that initializes the dictionary containing the target letters (used to track what letter has been guessed)
A part that handles the user's guesses and related logic.
Create the following functions with the following specifications to cover the above three parts of the code respectively.
A function to get the target word: This has no input and returns a string containing the word.
A function to initialize the letters in the dictionary: This takes in no input but returns the dictionary containing the letters in their default False states.
A function to process each turn, where all the guessing logic is carried out: This takes in a string containing the input provided by the user and performs the operations that processes the input. Nothing is returned by the function.
Notes:
Be sure to use descriptive names and proper naming conventions when naming your functions.
Modify your code as needed to make use of the function calls instead.
Modify your existing code to use functions.
We can think of the current hangman code as consisting of 3 different parts:
Create the following functions with the following specifications to cover the above three parts of the code respectively.
Notes: