- 1
python search engine project
def search(text,word): if word in text: print("word found") else: print("word not found") text = input() word = input() search(text,word) this code gives the output but all the test cases are wrong please help
4 Answers
+ 5
Hatsy Rei , umm do you really think that there is need of .split()
18IS014_ Ashwin bro, Python is checks strictly, means 'A' and 'a' are two different things! It's not 'word' , write 'w' in upper case, means 'Word found' and 'Word not found'
Conclusion : make 'w' capital for pass the test cases
+ 3
Convert your input string in text to a list of words before performing the search.
text = input().split(' ')
+ 2
Rishav Tiwari Well... I imagine if you have text
"This is a string"
I would want the method to return true when searching for "string", but not "ring", since while "ring" is technically a substring of text, I'm looking for a word. Not sure if this is a test case, but it is something worth noting.
- 1
Rishav Tiwari;
thanks for this it worked i finished my course