Skip to content

Instantly share code, notes, and snippets.

@imjohsep
Created October 24, 2013 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjohsep/7145333 to your computer and use it in GitHub Desktop.
Save imjohsep/7145333 to your computer and use it in GitHub Desktop.
Written by the Introduction to Python class at Noisebridge during October 23rd's class. I've refactored the our original code, so we now have one function in main running the two game functions and additional comments for each definition.
#!/usr/bin/pyhton
'''
password_guess.py takes a user provided password and gives the next user
3 attempts to correctly guess the password before exiting the script.
'''
def checkpassword(guess, password):
'''
Verifies whether a guess is correct match to a user's password
'''
if guess == password:
print "good job!"
exit(1)
else:
print "password not match"
def vault(password):
'''
Vault records guesss attempts and passes guesses and password
to checkpassword().
'''
attempt = 1
while attempt < 4:
guess = raw_input("Make your guess: ")
checkpassword(guess, password)
attempt += 1
print "sorry too many trys..."
if __name__ == '__main__':
print "User, enter your password por favor: "
password = raw_input()
vault(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment