+ 1

Python Project

Need help on the python search engine project. I'm stuck.

7th Feb 2022, 2:00 PM
Daphine Nzioka
Daphine Nzioka - avatar
4 odpowiedzi
+ 2
Had the if else statementa but I hadn't used the split function 🤦. Thank you
7th Feb 2022, 5:27 PM
Daphine Nzioka
Daphine Nzioka - avatar
+ 2
text = input() word = input() def search(text, word ): if word in text: return "Word found" else: return "Word not found" print(search(text, word))
7th Feb 2022, 7:40 PM
Daphine Nzioka
Daphine Nzioka - avatar
+ 1
All you need to do is make a function Function goes like this def search(text, word): # 1 # 2 # 3 # 4 # 5 1. In the first line, you're gonna want to split the text variable using the built-in function split(). The split function will split the string to a list. Example : x = "I ate a banana" print(x.split()) Output : ["I", "ate", "a", "banana"] 2-5. Here, you will want to use the if else statements. You should know how to check if an element is in a string considering you went that far in the lesson so I'll leave this one to you Refer to lesson 31.1 if you're having trouble with 2-5 Hope this helps, happy coding!
7th Feb 2022, 3:10 PM
Da GD Bot
Da GD Bot - avatar
0
Hold on
7th Feb 2022, 3:03 PM
Da GD Bot
Da GD Bot - avatar