Created
October 22, 2012 19:17
-
-
Save mooreniemi/3933483 to your computer and use it in GitHub Desktop.
for 600x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getGuessedWord(secretWord, lettersGuessed): | |
''' | |
secretWord: string, the word the user is guessing | |
lettersGuessed: list, what letters have been guessed so far | |
returns: string, comprised of letters and underscores that represents | |
what letters in secretWord have been guessed so far. | |
''' | |
count = 0 | |
blank = ['_'] * len(secretWord) | |
#print blank | |
for i, c in enumerate(secretWord): | |
if c in lettersGuessed: | |
count += 1 | |
#print count | |
blank.insert(count-1,c) | |
blank.pop(count) | |
#print blank | |
if count == len(secretWord): | |
return ''.join(str(e) for e in blank) | |
else: | |
count += 1 | |
blank.insert(count-1,'_') | |
blank.pop(count) | |
if count == len(secretWord): | |
return ''.join(str(e) for e in blank) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment