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!")

25th Jul 2023, 6:44 PM
NSC
NSC - avatar
8 ответов
+ 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...
25th Jul 2023, 7:06 PM
Riya
Riya - avatar
+ 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.
25th Jul 2023, 7:09 PM
Ausgrindtube
Ausgrindtube - avatar
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!
25th Jul 2023, 9:08 PM
Meiqdad Hassani
Meiqdad Hassani - avatar
0
Ok
26th Jul 2023, 8:33 AM
NSC
NSC - avatar
0
Sorry doesn't work
26th Jul 2023, 9:24 AM
NSC
NSC - avatar
0
Can you please attach your code as per this instruction: https://code.sololearn.com/Wek0V1MyIR2r/?ref=app
27th Jul 2023, 7:51 AM
Ausgrindtube
Ausgrindtube - avatar