0

I need help

print ("Change the password:") print ("\n✓Enter the ancient password:") ancient_password = int(123) print (ancient_password == int(input())) if ancient_password True: print("correct") # I need Help

4th May 2023, 2:59 AM
Reda El
10 Respostas
+ 7
Hamza El , I made some changes to your code...try like this... https://code.sololearn.com/cQBFKQMvJzm6/?ref=app
4th May 2023, 5:25 AM
Riya
Riya - avatar
+ 5
Hamza El , For what you are entering new password ... In if statement itself we check whether it is true or not... This line is not needed in else statement...
4th May 2023, 7:24 PM
Riya
Riya - avatar
+ 3
Hamza El try to save the input value to a variable then compare it with your ancient_password with if condition. EnteredPassword=int(input()) If EnteredPassword is ancient_password: ...... else: .......
4th May 2023, 4:08 AM
Yasin Rahnaward
Yasin Rahnaward - avatar
4th May 2023, 7:12 PM
Riya
Riya - avatar
4th May 2023, 7:05 PM
Reda El
+ 1
design issues aside, this line is invalid: if ancient_password True: ancient_password is still 123, which is not True in python afaik, so even if you remembered to include an == in that statement it wouldn't work because it'll always be false (and if this were C, 123 *would* evaluate to true so you'd have the opposite problem)
4th May 2023, 5:06 AM
Orin Cook
Orin Cook - avatar
+ 1
print("Change the password:") ancient_password = "123" print("Enter the ancient password:") if ancient_password == input(): print("Correct") else: print("Incorrect") Here is a modified version, if there is something wrong with it, let me know
5th May 2023, 1:06 PM
Donovan Holzhausen-McCarrick
Donovan Holzhausen-McCarrick - avatar
0
Riya I want to enter the New password but error https://code.sololearn.com/cuyRLK1FkwI8/?ref=app
4th May 2023, 7:17 PM
Reda El
0
probably you'ee running into a limitation of the code bits environment: you can only enter inputs at the beginning, but you can enter multiple inputs on separate lines and it'll take them one at a time. So give it two numbers at the start when you run it, and it should work. That said, a) you forgot to convert input to int, and b) "is" is not the same as ==, and will never return true here. "is" asks if they're the same object, which different variables aren't.
4th May 2023, 7:39 PM
Orin Cook
Orin Cook - avatar
0
Donovan Holzhausen-McCarrick I want to rewrite the second input but it display error https://code.sololearn.com/cuyRLK1FkwI8/?ref=app
5th May 2023, 1:56 PM
Reda El