Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how do i write this code ? I am confused on how to code the hangman one so can someone please help me. 1) [20
how do i write this code ?
I am confused on how to code the hangman one so can someone please help me.
1) [20 marks] Write a function named eceery queas which will take the list of lefters already guessed (initialy, this will be an empty list). The function asks the user to enter a single ieter and error checks to ensure that exacty 1 alphabetic charactur is entered. It will also check to see if the letter has already been guessed. The single letter will be retumed. For example: 33) gows 1ist = I'a', 'b', 'c'] (3) gutis o enter_Gous(sues__1ist). Enter a Iettee : 3 Please *nter 1 and only 1 letteri s Please titer I and anly 1 letteec b You have already cuessed that letter. Try anether: c You have already cuessed that 1etter. Try atather: ty Please enter I and onty 1 letteen d a print (eutss). 2) [10 marks) Wrile a function called get_ kerd which takes at list of words and randomly rebums one word. You must use either randow. randint of randen. chotees. For example: 300 target = get_word(words ) mop print(target) student 3) 660 marks) Wrile a function called zangran which takes a string (a target word) as a parameter. This function displays the inifial gallows and the number of underscores in the target word. As long as the target word has not been guessed or the user has not incorrectly guessed 7 letters, get a letter from the user (calt enter_quess), if the letter is not in the target word, increment a counter that keeps track of the number of incorrect guesses and add one more piece to the galiows. If the lener is in the target word, replace the underscore in the location of the letfer, with the letter. Then display the underscores (possibly including letters) and the lethen guessed (aerted alphabetically). Once the target word has been guessed or the user has incorrectly guessed 7 letters, display the resuts. See screenshots at end. The join methed (a string method) can be very helptul in tris function. It takes an merable (ike alist) as a parameter and produces astring with the initist string between each of the list items, eg." "+ + oin(t' a ","b ', " c ". " "d']) would produce the steing a b bd. Note: The Pythea style guide states that functions should be no longer than 20 lines of 3 code (a couple more is ok). This function wil require muct more than 20 lines. Therefore, it wil be helpful 10 witle helper functions that do pats of what's required, eg. creating the initial galows and displaying the results. 4) [10 marks] Write a function named main which takes no paramesen. This function calls gef wards to get a target word and then uses this to call the hasfin function. This function returns None. See the following pages for examples of the game being played Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started