Can you correction my code ,and give a correct code of search engine | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you correction my code ,and give a correct code of search engine

text = input() word = input() def search (word ,text) : if word in text: print("word found") else : print"word not found" search(word,text)

10th Jul 2021, 2:34 AM
Christopher Bernard Wintara
15 Answers
+ 2
text = input() word = input() def search (word ,text) : if word in text: print("word found") else : print("word not found") search(word,text)
10th Jul 2021, 2:41 AM
Christopher Bernard Wintara
+ 1
Check your output strings and make sure they match 100% (including capitalization and punctuation etc) what the expected output should be. Your print() function call in the else statement is missing the parentheses ().
10th Jul 2021, 2:40 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
The search function is supposed to 'return' the correct string to be output. There should be only 1 print() call in the code and if statement or else statement should return the correct value string depending on whether the word was found in the text or not.
10th Jul 2021, 2:58 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks for your help I AM "TIME" i understand what the problem
10th Jul 2021, 3:55 AM
Christopher Bernard Wintara
+ 1
Christopher Bernard Here's a shorter version of your corrected code: def search(word, text): print("word"+" not"*(word not in text)+" found) text = input() word = input() search(word, text) # Hope this helps
11th Jul 2021, 4:07 PM
Calvin Thomas
Calvin Thomas - avatar
0
I allready take the parenthese (),but its not true
10th Jul 2021, 2:41 AM
Christopher Bernard Wintara
0
I allready put capital W to each word but its nit true
10th Jul 2021, 2:48 AM
Christopher Bernard Wintara
0
Christopher Bernard Your code works well just change "word" to "Word" in print statement.
10th Jul 2021, 3:52 AM
A͢J
A͢J - avatar
0
Can you please tell the error???
10th Jul 2021, 1:41 PM
nithin.k.s
nithin.k.s - avatar
12th Jul 2021, 1:37 AM
Abhishek Kumar
Abhishek Kumar - avatar
- 1
you forgot parenthesis in second print statement ;)
10th Jul 2021, 2:39 AM
visph
visph - avatar
- 1
you must put capital W at 'word' in both...
10th Jul 2021, 2:42 AM
visph
visph - avatar
- 1
check the task description: maybe it must be some punctuation... or other ;P
10th Jul 2021, 2:49 AM
visph
visph - avatar
- 1
did all tests fail, or only some?
10th Jul 2021, 2:54 AM
visph
visph - avatar
- 4
Firstly you did not put Parenthesis in the print statement for else. Secondly, if your program requiers input then there is no need to call the function at the end, unless in cases where you would want it to return the function. Also while calling your function, you cant use the args used to define it. Here is an example of a working code: def search (word ,text) : if word in text: print("word found") else : print("word not found") search(“mike”, “My brother mike plays soccer”) Or text = input(“Please input a text: “) word = input(“Please input the search word: ”) def search (word ,text) : if word in text: print("word found") else : print("word not found") I think this might be what you want??
10th Jul 2021, 9:20 PM
Gideon Okike
Gideon Okike - avatar