+ 3
The code doesn't work I need help
text = input() word = input() found = "Word found" nfound = "Word not found" def search(text, word): if text in word: return found else: return nfound print(search(text, word)) the code i wrote did not work. 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 please help solve the problem.
3 odpowiedzi
+ 3
text = input()
word = input()
found = "Word found"
nfound = "Word not found"
def search(text, word):
words = text.split()
if word in words:
return found
else:
return nfound
print(search(text, word))
Hope above code will help you !!!
It works for list check for
tuple
set
dict (dictionary)
+ 2
thanks
+ 2
def search(text, word):
if word in text.split():
return "Word found"
else:
return "Word not found"
print(search(input("enter text: "), input("enter word: ")))