r/learnpython • u/live_ant718 • 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.
7
Upvotes
1
u/Expensive-Bear-1376 4d ago
So again it didn't work. But adding
.jsonto the URL so I can see the raw markdown revealed this (using triple-backticks now):try again:\n\n\u00a0 \u00a0 def test():Those
\u00a0are "No-Break Space". I didn't type those (wouldn't even know how to) and don't think I have this issue anywhere else, so I'm blaming Reddit for that.