+ 4
I don't understand at all what the mistake is. Аlready tried everything. Will you help?
6 Antworten
+ 3
I think you might be confused of the joined branch of your if-else-branches? That's due to your conditions:
if y == "good" or "fine" or ...
You either have to compare your 'y' with each string separately like this:
if y == "good" or y == "fine" or ...
... or you put the values into a list:
if y in [ "good" , "fine" ... ]
+ 3
Somehow, yes. Actually it is evaluated as "anything" is not false. 😉
+ 2
You need to state complete expressions between multiple logical operators.
if (expr1) or (expr2) and (expr3) etc.
if (var == "val") or ("anything")
... is not an evaluable expression, since "anything" has no (boolean / logic) meaning at all.
+ 1
# check line 3, 6 and 8
print ("hello")
x=(str(input()))
if x in ["hello", "hi", "hey"]:
print ("how are you")
y=(str(input()))
if y in ["good", "fine", "perfect", "nice"]:
print ("I'm happy for you, I'm fine too")
elif y in ["bad", "verybad", "shitty"]:
print ("Everything will be alright")
else:
print("im not understand")
# Dont give up, this is good code
+ 1
Sandra Meyer Can you explain in more detail, please, why "y" needs to be compared separately and not all together?
+ 1
Sandra Meyer Thanks bro. The program did not work because "y" was not compared with each word separately, but these words were "as if compared" with each other. Did I understand correctly?