+ 4

I don't understand at all what the mistake is. Аlready tried everything. Will you help?

https://code.sololearn.com/cQwx65m4jFgY/?ref=app

13th Aug 2020, 10:56 PM
иван
иван - avatar
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" ... ]
13th Aug 2020, 11:04 PM
Sandra Meyer
Sandra Meyer - avatar
+ 3
Somehow, yes. Actually it is evaluated as "anything" is not false. 😉
14th Aug 2020, 9:51 AM
Sandra Meyer
Sandra Meyer - avatar
+ 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.
13th Aug 2020, 11:16 PM
Sandra Meyer
Sandra Meyer - avatar
+ 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
13th Aug 2020, 11:01 PM
Steven M
Steven M - avatar
+ 1
Sandra Meyer Can you explain in more detail, please, why "y" needs to be compared separately and not all together?
13th Aug 2020, 11:12 PM
иван
иван - avatar
+ 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?
14th Aug 2020, 9:45 AM
иван
иван - avatar