diff --git a/learning/01-password-checker/password_checker.py b/learning/01-password-checker/password_checker.py new file mode 100644 index 0000000..606271e --- /dev/null +++ b/learning/01-password-checker/password_checker.py @@ -0,0 +1,21 @@ +import random +import getpass +def check_password(user_input, correct_password): + return user_input == correct_password +failure_messages = [ + "CIA farm boys alerted", + "NSA coordinating with NORAD", + "UNSC notified of impending domestic launch", + "Thermonuclear war initiated", + "Rerouting through the Pentagon", +] +max_attempts = 5 +attempts = 0 +while attempts < max_attempts: + user_input = getpass.getpass("Enter password: ") + if check_password(user_input, "joshua"): + print("Access granted!") + break + else: + attempts += 1 + print(f"Attempt {attempts} of {max_attempts}: {random.choice(failure_messages)}") \ No newline at end of file