+ 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))

7th Apr 2022, 4:18 AM
xy._.
xy._. - avatar
13 odpowiedzi
+ 8
def(): if(): return something else: return another thing argument1 argument2 print()
7th Apr 2022, 4:50 AM
Simba
Simba - avatar
+ 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.
7th Apr 2022, 4:51 AM
Brian
Brian - avatar
+ 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
7th Apr 2022, 3:32 PM
Lothar
Lothar - avatar
+ 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!
8th Apr 2022, 8:38 AM
xy._.
xy._. - avatar
+ 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!
7th Apr 2022, 4:11 PM
Korkunç el Gato
Korkunç el Gato - avatar
7th Apr 2022, 4:28 PM
UNKNOWN
+ 3
def search(text,word) if(text==word): Print("found") else: Print("not found") text=input() Word=input() search(text,word)
7th Apr 2022, 10:31 AM
UNKNOWN
+ 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 :-)
7th Apr 2022, 4:38 PM
Korkunç el Gato
Korkunç el Gato - avatar
+ 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 .
7th Apr 2022, 3:37 PM
UNKNOWN
+ 2
Korkunç TheTerrible Ok bro I am sorry that's my mistake
7th Apr 2022, 4:15 PM
UNKNOWN
+ 2
Lothar Sorry bro if I was rude
7th Apr 2022, 5:00 PM
UNKNOWN
+ 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))
8th Apr 2022, 6:51 PM
Stuart
+ 1
text = input() word = input() x = text y = word if y in x: print("Word found") else: print("Word not found")
8th Apr 2022, 7:19 PM
Anayo Ezinwanne Amarachi
Anayo Ezinwanne Amarachi - avatar