+ 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
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.
+ 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.