+ 1

Can someone explain the last line of code?

word= input() text = input() def search(text, word): if word in text: return ("Word found") else: return("Word not found") print(search (word, text))#why is this line of code needed

3rd Mar 2022, 4:32 PM
Emmanuel Owusu oppong
Emmanuel Owusu oppong - avatar
3 Answers
+ 5
Emmanuel Owusu oppong , there is a function called *search(..., ...)* that will be called in the last line of code. 2 arguments are passed to the function: *word* and *text*. the function returns a value (string) that will be printed by the *print(...)* function in the last line of code.
3rd Mar 2022, 4:38 PM
Lothar
Lothar - avatar
+ 2
That line of code needed because we are calling the function search The search function is defined by the user. So if you want to use user defined functions, you need to call them first.
3rd Mar 2022, 5:22 PM
Ritu
+ 2
Thanks so much, Lothar and RiTu
4th Mar 2022, 2:59 AM
Emmanuel Owusu oppong
Emmanuel Owusu oppong - avatar