+ 2

Can you fix this Code

Print("Please login") Password = ("Login") Login = input("Please Enter your Password :") if Login = (Password) #<---- Invalid Syntax print("Logged in"): else print("Wrong password")

26th Aug 2019, 10:24 PM
Denis kretz
Denis kretz - avatar
3 Answers
+ 3
For comparisons, you have to use == instead of =. The = symbol declares a variable something while the == symbol returns True if both values are the same, False if they aren't.
26th Aug 2019, 10:29 PM
CeePlusPlus
CeePlusPlus - avatar
+ 1
print("please login") password = "Solo" userPassword = input("Please Enter your Password:\n") if userPassword == password: print("logged in") else: print("wrong password") errors: - you forgot the ':' at the end of the if-statment and at the end of the else-statment - the print-statment shouldn't be 'Print', but 'print' - '=' was used for comparison, but it should have been '==' - you put a ':' at the end of an print statment logical errors: - password stores a tuple('()') containing the actual password, and when comparing, the user-input is compared against a tuple of the variable password -> password in tuple in tuple hope this helps! happy coding!! 😄
26th Aug 2019, 11:44 PM
Anton Böhler
Anton Böhler - avatar
+ 1
Thanks 👍
26th Aug 2019, 11:46 PM
Denis kretz
Denis kretz - avatar