does anyone else get the bug of user = input() failing to work?
theopythontest (2)

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.

You are viewing a single comment. View All
robowolf (550)

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 (288)

also indent the

print("I don't understand")

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

theopythontest (2)

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

theopythontest (2)

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

theopythontest (2)

@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 (550)

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