If condition is not working for some reason

while True:
    inp = input("Say hi bruh!: ").lower
    if inp == "hi":
        print("Okay")
        break
    else:
        print("Not Okay")
        continue

It either doesn't enter the condition or something. I know Python for a while and can't figure out what is wrong.

Upvotes: 0

Views: 182

Answers (2)

Anirban Bhattacharya
Anirban Bhattacharya

Reputation: 12

Just put a bracket after lower as it is a function. It is necessary to put a bracket in case of functions.

while True:
    inp = input("Say hi bruh!: ").lower()
    if inp == "hi":
        print("Okay")
        break
    else:
        print("Not Okay")
        continue

Upvotes: 0

scottdraper8
scottdraper8

Reputation: 43

As Joran stated in the comment, you're missing the parentheses after lower. Once you add those your loop will work. Python cannot successfully interpret your variable inp without them.

while True:
    inp = input("Say hi bruh!: ").lower()
    if inp == "hi":
        print("Okay")
        break
    else:
        print("Not Okay")
        continue

Upvotes: 1

Related Questions