r/learnpython • • Sep 06 '26

Password guesser game help needed

Hello guys. So I have created a password guesser game with direct comparison (i.e. if guess == correct_password:) but I want to use different methods for comparison. What techniques can I use? Here is the code-

```python

password = "Random_pass_123"

tries = 0

while tries < 3:

guess = input("Enter the password: ")

if guess == password:

print("Admin access granted.")

break

else:

print("Invalid credentials entered. Please try again")

tries += 1

if tries == 3:

print("Number of tries exceeded. Access denied")

```

PS- Is this the right way to paste code? I'm new so I'm not sure.

7 Upvotes

31 comments sorted by

View all comments

Show parent comment

0

u/Bright_Mix_773 Sep 09 '26

That one worked, it is rendering as a code block. The usual reason it fails the first time is a missing blank line before the block, or the editor turning the four spaces into a tab on the way in. If it happens again, paste into a plain text editor first and look at what is actually in front of the line.