0
Need help explaining why this doesn't work for the final 100 points bonus question for Python for Beginner course.
This is the code I have, not sure why this doesn't work... Anyone would be willing to shed some light? Thanks Problem #45 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 a function called search(). The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not. Sample Input "This is awesome" "awesome" Sample Output Word found ----------------------- #My code below text = input() word = input() def search(text,word): if word in text: print ('Word found') else: print ('Word not found') print (search (text,word))
5 Antworten
+ 1
k2hawk 10
Try this:
def seacrh(text,word) :
if word in text :
print ('Word found')
else:
print('Word not found')
text = input()
word = input()
seacrh(text,word)
+ 3
Oh, ya just use;
search(text, word)
or return the values from the function instead of printing them in the function.
+ 1
Check your output strings! Case matters, punctuation matters, etc. Must match 100%
"Word Found" != "Word found"
"Word Not Found" != "Word not found"
+ 1
LoL thank you! ChaoticDawg
0
ChaoticDawg thanks, I tried that it's doesn't work still. The last print(search(text,word)) seems to be giving me trouble. Any other suggestions?
Test #1 output expects
"Word found"
But my output came out to be (two outputs)
Word found
None