# File: tuThPassword.py # Author: Dr. Gibson # Date: 9/27/2016 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that allows the user # to guess a password, stopping them once they're reached # 3 tries or guessed correctly, and prints out a message. def main(): MAX_TRIES = 3 password = "dogsRule" # get a guess from the user guess = input("What is your guess for the password? ") numTries = 1 # stop if the user has no tries left, or they guess right while numTries < MAX_TRIES and guess != password: print("Please try again") numTries = numTries + 1 guess = input("What is your new guess for the password? ") # we've exited, print out the results if guess == password: print("Access granted.") else: print("Access denied.") main()