+ 2
Challenge help please!
The point to this code is to search some text for a word. My code below keeps printing "none" after it gives the correct output. I have no idea why it does this. Please Help! text = input() word = input() def search(t, w): """searches for a word within a string of words and reports whether or not the word is found in the text """ words = list(t.split(" ")) count = 0 for word in words: if w == words[count]: return print("Word found") else: count += 1 if count >= len(words): return print("Word not found") print(search(text, word))
2 Respuestas
+ 8
Tabetha Ridgway , the reason why it outputs "None" is that you return not only the output message, but also the print() statement.
remove print() in all return expressions.
happy coding;
+ 1
check this out
https://code.sololearn.com/cZwW8ijPr96Y/?ref=app