Asked by Reece

How do you check if the words exist in the sentence in Python?

So far I have got...

the_sentence = ("I love chocolate and chocolate loves me")
sentence = the_sentence.split()
print(sentence)
sentence_1 = raw_input("Enter a word")
def "word":
if word in the_sentence:
print "Yes"
elif word not in the_sentence:
print "Nope"

Thanks

Answers

There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions