Linked Questions

Popular Questions

how to make a code using many definitions for wheel fortune code?

Asked by At

Write a one-player game that has the user attempt to guess a secret phrase. If the user guesses the phrase she/he wins. If not, he she loses. After the game ends, ask the user if he/she wants to play again.

The secret phrase is randomly chosen by the computer program from a list of possible secret phrases. The user enters a guess. The program should check that the entered guess has not already been guessed. If the letter IS in the secret phrase, it is added in the correct position in the secret phrase and displayed. If the letter is NOT in the secret phrase, it is added to the list of missed letters. If the user makes 5 incorrect guesses, she/he loses.

If the user loses the game, the program displays "You lost. The secret phrase was _____". If the user wins, the program displays "Congratulations, you won a trip to Colorado!" ***** The programmer should supply his/her own "prize" - be creative!

CONSTRAINTS:

1) The code cannot add a blank (‘ ‘) to string “correctLetters”

2) Code must use slicing for displayBoard (as it does in hangman.py)

NOTES:

We will be developing a testing criteria document together. Be sure you have tested your program thoroughly according to the criteria before handing it in.

this is what it is supposed to look like but my outcome is always completely different.

my code:

import random
def replaceWithDashes(string):
    dashes = ""
    #fill in here
    return dashes

def revealSpotInPhrase(phrase,spot,original_phrase):
    #fill in here
    return new_phrase

def isLetterInPhrase(string,letter): 
    #fill in here
    return "false"

def isGuessAVowel(letter):
    #fill in here
    return "false"

def gameOverMessage():

    print("Game Over!")            

def playerGuess():
    guess = raw_input("Your guess: ")
    guess = guess.upper()
    return guess

def revealAllOfGuess(current_phrase, original_phrase, guess):
    count = original_phrase.count(guess)
    startSpot = 0
    new_phrase = current_phrase

    for i in range(0, count):
        replaceSpot = original_phrase.find(guess, startSpot)
        new_phrase = revealSpotInPhrase(new_phrase,replaceSpot, original_phrase)
        startSpot = replaceSpot + 1

    return new_phrase


print("Welcome to Wheel of Fortune!")
original_phrase = "THE SAN FRANCISCO GIANTS"
current_phrase = replaceWithDashes(original_phrase)

enter image description here

enter image description here

enter image description here

my code and the outcome

Related Questions