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

Function askForPlayerGuess

src/gamesbyexample/hacking.py:165–173  ·  view source on GitHub ↗

Let the player enter a password guess.

(words, tries)

Source from the content-addressed store, hash-verified

163
164
165def askForPlayerGuess(words, tries):
166 """Let the player enter a password guess."""
167 while True:
168 print('Enter password: ({} tries remaining)'.format(tries))
169 guess = input('> ').upper()
170 if guess in words:
171 return guess
172 print('That is not one of the possible passwords listed above.')
173 print('Try entering "{}" or "{}".'.format(words[0], words[1]))
174
175
176# If this program was run (instead of imported), run the game:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected