MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / drawGuillotine

Function drawGuillotine

src/gamesbyexample/guillotine.py:117–141  ·  view source on GitHub ↗

Draw the current state of the guillotine, along with the missed and correctly-guessed letters of the secret word.

(missedLetters, correctLetters, secretWord)

Source from the content-addressed store, hash-verified

115
116
117def drawGuillotine(missedLetters, correctLetters, secretWord):
118 """Draw the current state of the guillotine, along with the missed and
119 correctly-guessed letters of the secret word."""
120 print(GUILLOTINE_PICS[len(missedLetters)])
121 print('The category is:', CATEGORY)
122 print()
123
124 # Show the previously guessed letters:
125 print('Missed letters:', end=' ')
126 for letter in missedLetters:
127 print(letter, end=' ')
128 print()
129
130 blanks = '_' * len(secretWord)
131
132 # Replace blanks with correctly guessed letters:
133 for i in range(len(secretWord)):
134 if secretWord[i] in correctLetters:
135 blanks = blanks[:i] + secretWord[i] + blanks[i+1:]
136
137 # Show the secret word with spaces in between each letter:
138 for letter in blanks:
139 print(letter, end=' ')
140
141 print()
142
143
144def getPlayerGuess(alreadyGuessed):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected