- 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

27th Jul 2021, 11:45 AM
18IS014_ Ashwin
18IS014_ Ashwin - avatar
4 ответов
+ 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
27th Jul 2021, 12:04 PM
Abhiyantā
Abhiyantā - avatar
+ 3
Convert your input string in text to a list of words before performing the search. text = input().split(' ')
27th Jul 2021, 11:48 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
27th Jul 2021, 12:06 PM
Hatsy Rei
Hatsy Rei - avatar
- 1
Rishav Tiwari; thanks for this it worked i finished my course
27th Jul 2021, 12:19 PM
18IS014_ Ashwin
18IS014_ Ashwin - avatar