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.

6 Upvotes

31 comments sorted by

View all comments

3

u/live_ant718 Sep 06 '26

Also IDK where the indentations have gone.

3

u/AlexMTBDude Sep 06 '26

Look at the edit box when you write the text. There's a button for telling Reddit you're pasting code. https://support.reddithelp.com/hc/en-us/articles/360043033952-Formatting-Guide

2

u/Langdon_St_Ives Sep 06 '26

Reddit changed the app to no longer accept standard markdown syntax as it used to. They force you to use the UI controls instead, but didn't bother to add support for code. So now there is no way at all to get code markup (neither in-line nor fenced code block as you tried it) at all on the app which is idiotic.

2

u/brasticstack Sep 06 '26

Triple backticks work, but the backticks need to be on their own line. Reddit's markdown doesn't accept language hints, so "```python“ is incorrect.

2

u/Langdon_St_Ives Sep 06 '26

Alas this doesn't work on the app any more

2

u/brasticstack Sep 06 '26

bummer. It's the only thing that works for me in my mobile browser. The four spaces prefix thing doesn't for me.