What is wrong in this code ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is wrong in this code ?

This is last practice test of phython beginners level.I am getting the right answer but with word ‘none’ Please tell me how to fix this. text = input().split() word = input() def search(text,word): if word in text: print("Word found") elif word not in text: print("Word not found") print(search(text,word))

8th Oct 2021, 3:39 AM
Rip
5 Answers
0
def search(text,word): if word in text: print("Word found") else: print("Word not found") return "" text = input() word = input() print(search(text, word))
8th Oct 2021, 3:54 AM
Eashan Morajkar
Eashan Morajkar - avatar
0
Eashan morajkar, i used return but the code is still returnind word ’none’.
8th Oct 2021, 4:43 AM
Rip
0
You want the function to return the string. Change it so you return "Word not found" or "Word Found". Make sure you use if word in text. Crazy you're still stuck on this? I completed the entire python for beginners course in the time since you asked this question and managed to solve it.
8th Oct 2021, 4:58 AM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
0
Idk it is showing none with word found
8th Oct 2021, 4:59 AM
Rip
0
Did you remove .split as well?
8th Oct 2021, 5:04 AM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar