add password checker - lesson 01
This commit is contained in:
@@ -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)}")
|
||||
Reference in New Issue
Block a user