0

Shed some light here please! I'll start with a few snippets and show you my issue.

Import random

question = input()

whoAnswers = ["array", "of", "who", "answers", "here"]

how answers = ["you know", "where", "I'm", "going", "with this"]

If question.split()[0] == "who" or "Who":

print(random.choice(whoAnswers))

Elif question.split()[0] == "how" or "How":

print(random.choice(howAnswers))

Else: print("I can't answer that.")

When you put an input of: how do I get rich? The output would be something from the whoAnswers array instead of the howAnswers array. What am I doing wrong?

  • 1
    question.split()[0] == "who" or "Who" This does not do what you expect. You would need (question.split()[0] == "who") or (question.split()[0] == "Who") (or use a variable for the first word): As written here, you check whether the first string matches, or whether the second string is not the empty string, which it is -> always a match – ChrisB Aug 21 '21 at 23:52

0 Answers0