Can someone please tell me why is there an error? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone please tell me why is there an error?

print("Please answer this survey") x = input(str("How are you feeling today?: ")) print(x) y = "Good", "Fine", "Happy", "Excited" z = "Bad", "Sad", "Not okay", "Not good" if x = y print("Good to know :)\)") if x = z print("Cheer up!! I'm always here for you :)\)")

23rd Mar 2020, 9:28 AM
Tonje
Tonje - avatar
1 Answer
+ 1
Once you turn <y> and <z> into a tuple or list, you can use `in` operator to check whether <x> exist in either tuple <y> or <z>. I would suggest to convert <x>, and also all values in <y> and <z> to lowercase, so that alphabet case wouldn't get in the way. if x in y: # <x> exists in <y> elif x in z: # <y> exists in <z> (Edit) You don't need `str` when reading input, just read input into <x>. x = input("Hello, how are you doing today?")
23rd Mar 2020, 10:17 AM
Ipang