0
My code doesn't work for some reason can u help me pls
My code: password = None while password != "Hello": password = input("Please enter the password:") if password != "Hello": print("Your password is incorrect.") print:("Correct password. Welcome!")
8 Answers
+ 5
NSC ,
Don't post your code in description tag... Write your code in code playground save it and share the code playground link here....
Indentation is not given properly...
And since you used if condition you have to use else condition to print the other statement...
And look at the last line print statement is wrong...
+ 3
Please, tag appropriately. Read this for that:
https://code.sololearn.com/W3uiji9X28C1/?ref=app
As to your code, it does work. Depending on what you want it to do.
Remember, Sololearn's compiler doesn't work with real-time input. You need to enter all of your inputs after you hit "run".
I tried your code like this:
"Run"
Help
Password
Hello
- then it output that I had to enter the password (which was your while loop), and for the final line, it said "correct password, welcome".
If you want it to output the "incorrect password" line, you need to indent it to fit inside your while loop.
0
Try this
password = input(please enter your password)
while True:
if password != "Hello":
print("Your password is incorrect.")
Else:
print:("Correct password. Welcome!")
Break
Sorry its long time I haven't work with python and now I haven't acces to PC to test but I hope it works!
0
Ok
0
Sorry doesn't work
0
Can you please attach your code as per this instruction:
https://code.sololearn.com/Wek0V1MyIR2r/?ref=app