Conquistador
Conquistador

Reputation: 37

conditional statement acting abnormal

def signUp():
    id=input("enter your id")
    password=input("enter your password")
    if (len(id) == 9 & len(password) > 4):
        print("YOUR ACCOUNT IS CREATED.....")
    else:
        print("Invalid ID or password")

Although I'm giving ID of length 9 and password of length greater than 4, still the condition isn't working. It's going to else always. But if I'm using nested if for ID and password, it's working fine.

Could you please help.

Upvotes: 0

Views: 22

Answers (1)

Mark Tolonen
Mark Tolonen

Reputation: 177901

& is bit-wise AND. You want logical and:

if len(id) == 9 and len(password) > 4:

Upvotes: 1

Related Questions