- 2

Please what is wrong in this code?

text = input() word = input() if ("word found")(search): print("word found") else: print("word not found") print(search(text, word))

9th Jun 2022, 8:59 PM
EmmzyCodez
EmmzyCodez - avatar
10 Answers
+ 3
Sobola Gabriel Pls don't give finished code in the answer. This is a learning app - if we don't allow the OP to write the code, we defeat learning. Always prefer giving hints to put the OP in the right direction. This allows for real learning.
11th Jun 2022, 7:30 PM
Emerson Prado
Emerson Prado - avatar
+ 5
The problem is lack of info in the question. Pls edit it, including: 1. A tag with the language 2. The code purpose 3. The results you found wrong Help those willing to help you.
9th Jun 2022, 10:59 PM
Emerson Prado
Emerson Prado - avatar
+ 2
Chiemerie Ekwueme E. Are you trying to resolve this using a function, or a simple if/else statement
9th Jun 2022, 11:07 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
The thing is you ain't using the variables you initialized in the if statement, you should have something like if text == or if text < or if word == or any condition as the case may be, that's missing in the code.
10th Jun 2022, 8:10 AM
Mayokun Timilehin
Mayokun Timilehin - avatar
+ 2
Chiemerie Ekwueme E. It's a bit clearer. Pls do the following for you to get real help, without forcing others to guess: 1. Put this explanation, about the code purpose, in the question description. Your explanation in an answer will get lost among the others. 2. Put your code in Code Playground and include a link to it (using "+" button) in the question description. This allows testing, debugging, and keeps the question updated. That said, there's two visible problems: The function call syntax in Python is 'function(arguments)', not '(arguments)(function)'; Well, no function 'search'. At least start it. Now, read about function 'split', and the test 'a in b'. This will help a lot. If you still have difficulties, first of all, follow the instructions above.
11th Jun 2022, 12:26 AM
Emerson Prado
Emerson Prado - avatar
+ 1
The logic in 'if' statement is not written correctly If you are doing this with a function then you need to provide the full code otherwise it leads to confusion and guesses about the functionality of your code.
10th Jun 2022, 3:33 AM
Sandeep
Sandeep - avatar
+ 1
Ok let me explain....... The given code should take a text and a word as input and pass them to a function called search(). The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not. I hope it is clear now
10th Jun 2022, 8:54 PM
EmmzyCodez
EmmzyCodez - avatar
+ 1
text = input(); word = input(); def search(text, word): text = text.split(); if word in text: return "Word found"; else: return "Word not found"; print(search(text, word)); This should solve your question if I got you really.
11th Jun 2022, 5:35 PM
Sobola Gabriel
Sobola Gabriel - avatar
+ 1
Thank you sirs🙌
11th Jun 2022, 6:29 PM
EmmzyCodez
EmmzyCodez - avatar
0
Python can't take two input.
10th Jun 2022, 12:39 PM
Victor [The Coder]
Victor [The Coder] - avatar