+ 3
What’s wrong with this code?
https://sololearn.com/compiler-playground/cCLX5gCn737U/?ref=app
25 Respostas
+ 7
The original code was:
password = input()
if password == password:
print("Good Job!")
else:
print("Try again.")
All that needed to be changed was line 2.
password = input()
if password == "1234":
print("Good Job!")
else:
print("Try again.")
+ 6
Abdulrahman ahmed, Gulam Raza, Laguras Xyreel Castromero, Gilbert Aquino This is not a general chat. Please see the community guidelines and start your own topic if you need help or have a coding related question.
https://www.sololearn.com/Discuss/3021159/?ref=app
+ 5
Solo yes typically
if input() == password: <- given that the password is an unknown variable in the test or if we as developers have defined it within our typical structure ...
And yes code changes as we discuss causes confusion as we are attempting to talk out what was wrong with the original code as new issues may be being made... Totally agree!
+ 4
Keith , I use the app on Android, and I also tried to find it in google, but to no avail...🤔
+ 4
Wong Hei Ming just modify the link by adding code. Subdomain to sololearn.com and delete compiler-playground
https://code.sololearn.com/cx2ym24wOxdO/?ref=app
+ 4
The onelink.me links are not sololearn links but a third-party
+ 4
Abdulrahman ahmed If you need help with an issue, you should start a new topic/thread by going to DISCUSS -> New Post
+ 3
BroFar, thank you.
But why couldn't I use the suggested link?
And this is not the first time...🤔
+ 3
BroFar , Newer Game , I understand that the code is still undergoing changes, which should not be done in the discussion as it is confusing.
But from what I see, it is possible to use data entry directly in the condition that the entered password will not be used anywhere else:
if input() == "password":
print("Good Job!")
else:
print("Try again.")
+ 2
You give a password as input. Then you check if the password you gave is equal to the password itself which is always true. So the code will output always the same result Good job.
+ 2
Black Winter, Keith
Strange, why do I only see the URL and can't follow this link?...🤔
+ 2
BroFar
Almost all the code links open on pc, no matter "compiler-playground" included or not.
Links doesn't open on pc are those on "code challenge", or linking to a feed.
+ 2
https://www.sololearn.com/discuss/3253969/?ref=app
I'm not sure what your orginal version was, but in the current version the problem is that you compare a non-existing variable 'input' instead of your actual variable called 'attempt'.
attempt = input()
if input == "password":
print("Good Job!")
else:
print("Try again.")
You can just change it to:
attempt = input()
if attempt == "password":
print("Good Job!")
else:
print("Try again.")
However, a better approach would be like this:
https://code.sololearn.com/cWwg51Vf2t9y/?ref=app
This will keep on looping untill correct answer is entered.
Note: in the app you can only give input once, so you will get an error at the second time it's waiting for input.
+ 2
Newer Game I see that you made some changes but it is still not working.
You can delete or comment out the first line and add parentheses to the input function 😉
#attempt = input()
if input() == "password":
+ 1
'If password == password' will always be True so you should change the value to the right of '==' to what you want the password to actually be 🔑
+ 1
Solo Many times the links only seem to work 'in app' 😕
+ 1
Change the variable captured by the user to something like 'attempt' and use 'if attempt == password:'
This will allow you to compare what the user has entered with the saved password.
You will need to define the variable 'password' somewhere above that line as well, set to whatever the correct password will be.
+ 1
Solo
When the link doesn't open, try to open it on the web version.
Mostly I use the web version unless the link doesn't open on pc, want to mention someone or post a code.
+ 1
Its not string