Python write a function which takes as a parameter the last promgram variable,return a string contai

import random

def isSecretWordGuessed(secretWord, lettersGuessed):
masked_secretWord = ""
for letter in secretWord:
if letter in lettersGuessed:
masked_secretWord += letter
else: masked_secretWord += "-"
print "The secretWord:", masked_secretWord

secretWords = ("action", "lights", "camera", "tripod", "filter")


secretWord = random.choice(secretWords)

guesses = 6
lettersGuessed = []

while guesses != 0:
letter = raw_input("Enter a letter: ").lower()

if letter in lettersGuessed:
print "You have already guessed that letter."
else:
guesses = guesses - 1
print "You have %d guesses left." % (guesses)
lettersGuessed.append(letter)
isSecretWordGuessed(secretWord, lettersGuessed)
secretWord_guesses = 1
secretWord_guess = 0
if secretWord_guesses == 1:
print "You get 1 guess to guess the secretWord."
else:
print "You get %d guesses to guess the secretWord." % (secretWord_guesses)
while secretWord_guess != secretWord_guesses:
guess = raw_input("Guess the secretWord: ").lower()
if guess == secretWord:
print "Congratulations, %s is the secretWord!" % (guess)
break
else:
print "Nope."
secretWord_guess += 1
if secretWord_guess == secretWord_guesses:
print "You ran out of tries! The secretWord was %s." % (secretWord)
Anonymous User
Anonymous User
Asked Dec 15, 2014

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Can you help them?

You may want to know:

Categories