Write a program called p4.py. Fill in the rest of the program, making use of the functions above, so that it does the following: 1. prompts the user to guess a character 2. validates the input. If input is invalid, then a message indicating so should be printed and the user should be prompted again. 3. Check if the character is in the word and print the word where only the guessed character is revealed, the rest of the letters should be replaced by underscores. 4. If the character is not in the word, then the number of incorrect guesses should be incremented 5. the hangman should be printed to reflect the number of incorrect guesses 6. the program should infinitely prompt the user to guess a character (repeating steps 1-5) until either the user enters ‘quit’ or the number of incorrect guesses reaches 6 Sample output (in the image pasted)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a program called p4.py. Fill in the rest of the program, making use of the functions above, so that it does the following:
1. prompts the user to guess a character
2. validates the input. If input is invalid, then a message indicating so should be printed and the user should be prompted again.
3. Check if the character is in the word and print the word where only the guessed character is revealed, the rest of the letters should be replaced by underscores.
4. If the character is not in the word, then the number of incorrect guesses should be incremented
5. the hangman should be printed to reflect the number of incorrect guesses
6. the program should infinitely prompt the user to guess a character (repeating steps 1-5) until either the user enters ‘quit’ or the number of incorrect guesses reaches 6

Sample output (in the image pasted)

Sample output -1:
Guess a letter:
Invalid input, please try again.
Guess a letter:
а а
Guess a letter: s
Guess a letter:
Guess a letter:
k
|
Guess a letter: quit
The word was 'koala’
Goodbyel
Transcribed Image Text:Sample output -1: Guess a letter: Invalid input, please try again. Guess a letter: а а Guess a letter: s Guess a letter: Guess a letter: k | Guess a letter: quit The word was 'koala’ Goodbyel
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education