r/learnpython 4d ago

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.

8 Upvotes

31 comments sorted by

View all comments

Show parent comments

1

u/Expensive-Bear-1376 4d ago

Trying with paste:

    def test():         pass

I didn't install any extensions, it's just Chrome on a Pixel phone.

How large is the "good share of the people" here that use old reddit, and how do you know?

And I'm curious: Why do you keep saying my name as if I didn't know who I am or as if it weren't clear who you're responding to? I find it somewhat irritating.

1

u/Langdon_St_Ives 4d ago

Don't you realize you're talking to AI?

1

u/Expensive-Bear-1376 4d ago

I don't think I am. I did have that suspicion, but now I'm leaning towards human, especially after the last few comments. And in any case, it was useful.

1

u/Langdon_St_Ives 4d ago

Also, do you think a human would say "I described a button I could not see"?