Ask coding questions

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

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.

Voters
theopythontest
Comments
hotnewtop
theopythontest

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

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

That should fix your problem.

LukeWright

also indent the

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

theopythontest

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

theopythontest

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

robowolf

@theopythontest So what is your question?

theopythontest

@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

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