cshw/py/Loops/task3.py

9 lines
No EOL
404 B
Python

# Keep asking for a passcode until the correct one is entered
while True:
passcode = input("Enter the passcode: ") # Prompt the user for input
if passcode == "1234": # Check if the input matches the correct passcode
print("Access granted!") # Confirm access
break # Exit the loop
else:
print("Incorrect passcode. Try again.") # Notify the user if incorrect