Editor

Check If a Word Is in a Sentence

Beginner · Write the code · from Python Strings: Create, Access, Slice, and Manipulate Text

From the lesson: Python Strings: Create, Access, Slice, and Manipulate Text

Think about your phone. Almost everything you see on the screen is text: names in your contacts, messages from friends, search results, notifications. Behind the scenes, all of that text is handled by strings.

Read the lesson

You are given a sentence and a search_word. Check if the search word exists in the sentence (case-insensitive) and print the result.

Expected output:

True

Convert both to the same case before checking.

sentence = "The quick brown Fox jumps over the lazy Dog"
search_word = "fox"
# Check if search_word is in sentence (case-insensitive)
# Print True or False

More Strings exercises

All Python exercises · 50 practice problems · Python Fundamentals quiz