0

I dont know what is wrong with my code plz help

text = input() word = input() def search (text , word): if text in word: print ("word found") else: print ("word not found") print (search (text ,word)) # any one knows what is wrong with my code # it must only print word found or word not found problem is it also print None which i dont know were it came from

1st Mar 2023, 5:33 AM
Redwan FZR
Redwan FZR - avatar
3 Réponses
+ 5
You should be checking whether <word> was part of <text>. You're doing it in reverse, you check whether <text> was part of <word> if word in text: # not text in word The search() function prints the status but it returns nothing. So you don't have to call print() again. Just call search() search( text, word ) # not print( search( text, word ) ) Make sure the output is exactly as the task required. Feel free to ask further in case anything wasn't clear ...
1st Mar 2023, 6:41 AM
Ipang
+ 2
Okay Good job!
1st Mar 2023, 7:05 AM
Ipang
+ 1
Thanks a lot it worked finally
1st Mar 2023, 7:04 AM
Redwan FZR
Redwan FZR - avatar