'using while loop+if to make a simple game but input line not working

after learned while loop and if, i m trying to make a super simple text game, but here is the problem: after the input line asked to type right/left, and no matter i type left or right, the code wont work. i changed the "choice" variable to left then it's working properly... I dont know what's the problems here...please tell me how to fix this to make it work.

choice=str(input("you are now in a forest, please pick a direction(left or right)"))
while choice == "right":
    print("a strange wind had sent you back to forest")
    choice=str(input("you are now in a forest, please pick a direction(left or right)"))
if choice == "left":
    print("u saw a cave, in or not?")
    choice= str(input("type in or not "))
    if choice == "in" :
        print("u saw a bear claw and that's the last view in your eyes")
    elif choice == "not":
        print("after two and a half hours walking, you are now out of the forest")

that's the code, I think the input line got some problems but I don't know what exact problems are. when I change to choice="right" or choice="left", the code is working but with this input line it's not...



Solution 1:[1]

This code is working for me; are you using all lowercase left or right with no quotes or other characters? You may want to add a .lower().strip() to the end of your input call to lowercase everything and remove leading/trailing whitespace.

Solution 2:[2]

sorry guys I just found out why! I have the habit to type a space between words which makes sentences clear but in this case, i type space+left/right and the while loop or if loop is looking for only "left' or "right" so I gave them a input they cannot recognize... that's stupid... I am so sorry thank you all for the help tho!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nate
Solution 2 beginnerboy