Home > Net >  If condition is not working for some reason
If condition is not working for some reason

Time:01-30

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.

CodePudding user response:

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

CodePudding user response:

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
  •  Tags:  
  • Related