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)
15 ответов
+ 2
text = input()
word = input()
def search (word ,text) :
if word in text:
print("word found")
else :
print("word not found")
search(word,text)
+ 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 ().
+ 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.
+ 1
Thanks for your help I AM "TIME" i understand what the problem
+ 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
0
I allready take the parenthese (),but its not true
0
I allready put capital W to each word but its nit true
0
Christopher Bernard
Your code works well just change "word" to "Word" in print statement.
0
Can you please tell the error???
- 1
you forgot parenthesis in second print statement ;)
- 1
you must put capital W at 'word' in both...
- 1
check the task description: maybe it must be some punctuation... or other ;P
- 1
did all tests fail, or only some?
- 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??