Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guess the word game help
So I have a guess the word game assignment need someone to help me fix it so the asteriks are synced with each word I did it before and just made the the words all the same length and got marked down, and then I need to make it to the word is being uncovered in the asterisks each time I guess a letter correctly I'm having issues figuring that out heres what I have so far

# Jack Crespin


#guess the word

import random 
name = input("What is your name? ") 
print("Good Luck ! ", name)

print ("Guess the word")
words = ['accept', 'acting', 'advice', 'beauty',  
         'python', 'before', 'player', 'beyond',  
         'artist', 'branch', 'boards', 'branch']  

word = random.choice(words) 
print("Guess the characters") 
guesses = '' 

turns = 9000
while turns > 0: 
    failed = 0
    for char in word:  
        if char in guesses:  
            failed += 1
    if failed == 0: 
        print("You Win")  
        print("The word is: ", word)  
    guess = input("guess a character:") 
    guesses += guess  
    if guess not in word: 
        turns -= 1
        print("You have", + turns, 'more guesses') 
        if turns == 0: 
            print("You Loose")

input ("press enter to continue")
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:

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?

Possibly Related Threads…
Thread Author Replies Views Last Post
  Word Game paulmerton4pope 4 533 Jul-11-2020, 02:50 PM
Last Post: paulmerton4pope
  Python Speech recognition, word by word AceScottie 6 9,284 Apr-12-2020, 09:50 AM
Last Post: vinayakdhage
  print a word after specific word search evilcode1 8 980 Oct-22-2019, 08:08 AM
Last Post: newbieAuggie2019
  can't figure out problem with number guess Galoxys 4 1,233 Oct-29-2018, 01:45 PM
Last Post: snippsat
  Guess a number Ameen 5 7,463 Apr-03-2018, 01:20 PM
Last Post: snippsat
  difference between word: and word[:] in for loop zowhair 2 1,539 Mar-03-2018, 07:24 AM
Last Post: zowhair
  Guess Random Number Why i m not able to enter input Nithya Thiyagarajan 6 4,544 Jan-07-2018, 04:26 AM
Last Post: squenson
  "Guess the Number" game CTT 14 5,898 Jul-26-2017, 11:41 AM
Last Post: sylas

Forum Jump:

User Panel Messages

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