Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guess the word game help
#2
How would you do this with pencil and paper? Pretend you are playing this game with a friend. First you pick a secret word, "before" for example, and write the initial guess word replacing each letter in the secret word with "*":

Guess = ******

Your friend guesses "e" so you update the guess word to display:

Guess = *e***e

Your friend guesses "r" and you update the guess word to display:

Guess = *e***re

How did you do that? I did that by looking at the secret word, finding where my friend's letter guess matches letters in the secret word, and replacing "*" at those positions with the guessed letter. The game is won when there are no "*" in the guess word. The game is lost when max number of guesses is exceeded.

To translate to code lets first look for objects in the solution description (look for nouns). My solution uses the following objects:

secret word
letter guess
guess word
"*"

Next I look for actions:
pick
guess
finding
replace

The actions are things my program is going to do, and the objects are things my program is going to use.

The winning and losing criteria need some fleshing out to get nice objects and actions, but you've already got that part figured out I think.

Does that help?
Reply


Messages In This Thread
Guess the word game help - by jackthechampion - Mar-30-2020, 12:29 AM
RE: Guess the word game help - by deanhystad - Mar-30-2020, 01:01 AM
RE: Guess the word game help - by annajenny - Sep-06-2023, 01:04 AM
RE: Guess the word game help - by Pedroski55 - Sep-06-2023, 06:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Ask again if wrong guess with While. EduPy 4 2,292 Oct-21-2021, 07:46 PM
Last Post: menator01
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,551 Aug-12-2021, 04:25 PM
Last Post: palladium
  I guess it's about print tsavoSG 2 2,147 Feb-08-2021, 08:34 PM
Last Post: steve_shambles
  Word Game paulmerton4pope 4 2,474 Jul-11-2020, 02:50 PM
Last Post: paulmerton4pope
  Python Speech recognition, word by word AceScottie 6 16,081 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  print a word after specific word search evilcode1 8 4,929 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  can't figure out problem with number guess Galoxys 4 3,389 Oct-29-2018, 01:45 PM
Last Post: snippsat
  Guess a number Ameen 5 13,190 Apr-03-2018, 01:20 PM
Last Post: snippsat
  difference between word: and word[:] in for loop zowhair 2 3,705 Mar-03-2018, 07:24 AM
Last Post: zowhair
  Guess Random Number Why i m not able to enter input Nithya Thiyagarajan 6 8,268 Jan-07-2018, 04:26 AM
Last Post: squenson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020