+ 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")
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.
+ 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!! đ
+ 1
Thanks đ