r/learnpython • u/live_ant718 • 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.
View all comments
Show parent comment
0
u/Bright_Mix_773 Sep 07 '26
Sorry about the name. That's a tic of mine and it adds nothing, so I'll drop it.
On "a good share of the people": I don't know, and I shouldn't have written it. Reddit doesn't publish that split and I have no number for it. Treat that part as withdrawn.
The advice under it survives, but for a different reason than the one I gave, and it has nothing to do with audience size. Old reddit renders a fenced block as inline code rather than a block: your triple-backtick comment further up has no
<pre>element on this page at all, just three inline spans. Four leading spaces is the only form that produces a real block on both sites. That's a property of the renderer, not of who happens to be reading.And your paste didn't survive either. The raw body of the comment you just posted indents with
160 32 160 32- nbsp, space, nbsp, space - and the eight-wide line keeps the same alternation going. Note it starts on the nbsp; I had that order backwards before. So: no extensions, and pasted text gets rewritten too. I said that case would be new to me. It is, and it moves the blame from anything on your end to the client itself.Which leaves one thing worth testing on a Pixel: old.reddit.com in Chrome. Its comment box is a real textarea rather than a contenteditable div, so there's no layer inside it that can substitute your whitespace. I won't promise it works - you've killed two of my guesses already - but it's the only box left that isn't the one doing the rewriting.