You are not logged in. Please login at to post your questions!


Help me out

How to print whether a word is in a sentence or not??? Like "I am a boy" and I have to check whether word "I" is there or not.

asked 11 Jan, 15:55

mdrzwan12's gravatar image

accept rate: 0%

Please delete your question. This question is from an ongoing contest and discussion of questions from ongoing contest is not allowed. Just wait for another 26 hours and you will come to know how to do it.


answered 13 Jan, 13:54

akash19jain's gravatar image

accept rate: 10%

A simple approach could be:

  • Take the sentence as input in a string
  • Break the sentence at all places where ' ' [space character] appears, and store them in a vector or array of strings.
  • Iterate through the vector of strings and compare each string, using STL you can also directly call find() function on the vector to search for the string.

Doing this in python is quite easy though.

sentence = "I am a boy"
words = sentence.split(' ') # split() the sentence
if "I" in words:
    print("I is present in the sentence.")


answered 11 Jan, 16:43

purohit's gravatar image

accept rate: 0%

edited 13 Jan, 11:46

This Question is similar to the 1st question in Jan19B Contest. Plz Delete or your would be penalinzed for plagarism.


answered 2 days ago

desmond_kaneki's gravatar image

accept rate: 0%

Hey, this is the 1st qestion of JAN LONG "FANCY QUOTES". Just delete your question man, you will get banned.


answered 2 days ago

koulick424's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 11 Jan, 15:55

question was seen: 164 times

last updated: 2 days ago