+ 1
Youâre working on a search engine. Watch your back Google! The given code takes a text and a word as input and passes them to
Hii I am stuck on this question as I don't know how to make my code to search whether the word is in the sentence or not. Can someone help? Thank you! Code: text = input() word = input() def search(text, word): if word in text: print("found") else: print("word not found") return search print(search(text, word))
13 Réponses
+ 8
def():
    if():
        return something 
    else:
        return another thing 
argument1
argument2
print()
+ 7
xy._. Python is very particular about indentation. Usually code doesn't work if you make up your own rules. Take some time to review and understand the real purpose for indenting code in Python.
Code Coach is very particular about matching your output with task requirements. Review the expected output and check your wording and capitalization.
+ 5
UNKNOWN ,
the sample / solution you posted has a real bunch of errors, that should be fixed. also you should use recommended indentation of 4 spaces for each level
def search(text,word) # missing colon at the end of the line
    if(text==word): # wrong conditional expression
      Print("found") # wrong spelling of print
    else:
      Print("not found") # wrong spelling of print
text=input()
Word=input() # wrong spelling of Word, see next line 
search(text,word) 
since you have not really started learning from a python entry level tutorial, it is recommended to do so.
happy coding
+ 5
Thank you everyone for trying to help me, really sorry for the wrong indention of the code as the formate was somehow wrong when I copy and paste it over. But now I have managed to solve my problem with all of your comments. Thank you very much!
+ 4
UNKNOWN That's kind of irresponsible because it looks like you wanted to care.
And why would you propose a solution without reading the question or the answers? looking for a word in a "sentence" is what it says.
You're not the one who's asking, you're the one offering the help. You don't have to. But if you do, you can show more care because if what you wrote weren't corrected, assuming you were being responsible, the people who know less would likely be more puzzled than before.  You practically had something to say for every mistake. lol, maybe you shouldn't be helping people, at least with codes, until you do it with more care, no? :-)
edit: thank you for not taking offense, because I wasn't meaning any, I'm a noob myself, so that's where it all came from. Just a little more attention will probably do. see you around!
+ 4
xy._. 
Lothar 
Korkunç TheTerrible 
Here is my code please check it 
https://code.sololearn.com/cJQMytzy86ln/?ref=app
+ 3
def search(text,word)
    if(text==word):
      Print("found")
    else:
      Print("not found")
text=input()
Word=input()
search(text,word)
+ 3
UNKNOWN I edited my previous response to thank you and tell you that I'm also a noob, but I can tell it looks good, at least to me. It should work.
BTW; from what I understand we're to neither ask for nor give a full solution directly as it could impede learning by encouraging passive participation. So people leave clues instead to make the asker get used to thinking a certain way, if that makes sense :-)
+ 2
Lothar 
thankyou for mentioning my mistakes 
1) since we are not writing in actual compiler so I did not care about the spelling mistakes
2) I forgot to put colon
3) I put text == word 
    Because I thought it's only one word to check  so I written text==word .
+ 2
Korkunç TheTerrible 
Ok bro I am sorry that's my mistake
+ 2
Lothar 
Sorry bro if I was rude
+ 1
text = input()
word = input()
def search(text,word):
    if(word in text):
        return "Word found"
    else:
        return "Word not found"
    
    
print(search(text, word))
+ 1
text = input()
word = input()
x = text
y = word
if y in x:
 print("Word found")
else:
 print("Word not found")



