techset techset - 2 months ago 11
Python Question

why can't i run an if statement if input is exactly a certain string not only in it (python)

My problem is i only want my if statement to run if the input is exactly the password not more or less but exactly the password. what it does is still works if it has extra characters on the end or beginning. for example say my password is


and i type


it will still say the password is correct, my code looks like this how can i fix it.

if esa in ("hi"):
print ("correct password")

userPassword = input("Enter password: ")
myPassword = "hi"
if userPassword==myPassword:
  print("Correct password")
  print("Incorrect password")

edit: it's really unclear what you want to be honest, this is just my best shot at helping you. if you comment with more info I can further help you!