Ask coding questions

← Back to all posts
does anyone else get the bug of user = input() failing to work?
theopythontest (0)

when editing my code the user = input() will randomly stop. for example my code is

user = input()

if user == hi or hello:
print("hello")
else:
print("I don't understand")

sometime the user = input() stops and the code will show hello to anything typed.

how can I stop this. my current solution is to rewrite the entire code.

Comments
hotnewtop
theopythontest (0)

the actually code is

print("Please enter IDENTIFICATION \n")
ID = input()
if ID == "test":
||print("Access Granted")
else:
||print("Access Denied")
print("")
print("Enter Command\n")

that is a part of the actual code. i have put | as indentation in this comment

robowolf (548)

First hi and hello have to be in quotes. Second the if should look like

if user == 'hi' or user == 'hello':
         print('hello') #don't forget to indent

That should fix your problem.

LukeWright (280)

also indent the

print("I don't understand")

@theopythontest click the checkmark next to robowolf's comment if they helped!

theopythontest (0)

@robowolf i forgot to add those in the question. ive provided a piece of the code now

theopythontest (0)

@LukeWright i forgot to add those in the question. ive provided a piece of the code now

theopythontest (0)

@robowolf at random times my code will glitch. it happens with all code. wether it is code ive wrote or code somone else has wrote. in the glitch any input() sections will stop working.

user = input()

if user == hi:
print("hi")
else:
print("bye")

this will then become

if user == any number or word :
print("hi")

robowolf (548)

@theopythontest Instead of word put a conditional statement like user == word