The given code takes a text and a word as input and passes them to a function called search(). | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 3

The given code takes a text and a word as input and passes them to a function called search().

error in my code , can you point it out??

4th Jun 2021, 9:51 AM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
13 Answers
0
Please give me correct code.
4th Jun 2021, 10:26 AM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
0
Oh right: #this is the real code I used to pass the module: def search(text,word): res = "" if word in text: res = "Word found" else: res = "Word not found" return res text = input() word = input() print(search(text, word))
4th Jun 2021, 11:27 AM
Ervis Meta
Ervis Meta - avatar
0
Ervis Meta Thank you very much...
4th Jun 2021, 12:54 PM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
0
def search(text_,word_): if word_ in text_ and word_: return "Word found" else: return "Word not found" text=input() word=input() print(search(text,word))
4th Jun 2021, 2:23 PM
Ratnapal Shende
Ratnapal Shende - avatar
0
Ratnapal Shende Thank you very much...
4th Jun 2021, 2:26 PM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
0
Siddhartha Kushwaha Here's a possible solution: def search(text, word): return word in text # Hope this helps
4th Jun 2021, 4:44 PM
Calvin Thomas
Calvin Thomas - avatar
0
Your Queue class is up and working in a customer service company. The company opens up a new branch and asks you to make another version of the Queue for them. The only difference is the way the Queue is displayed: each number on a new line. You decide to create a new class called Queue2, which is derived from the Queue class and overrides the print() method, outputting each element of the queue on a new line.
4th Jun 2021, 7:21 PM
عبدالكريم قاسم عدنان موسى
عبدالكريم قاسم عدنان موسى - avatar
0
Help C++
4th Jun 2021, 7:22 PM
عبدالكريم قاسم عدنان موسى
عبدالكريم قاسم عدنان موسى - avatar
- 1
My attempts:- def search(): text = input() word = input() if search == word: return text print("Word found") elif search ≠ text: return text print("Word not found") print(search(text, word))
4th Jun 2021, 9:57 AM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
- 1
Why do you stress youself with this long code. I think this is more readable : def search(word,text): result = None if word in text: result = True else: result = False return result
4th Jun 2021, 10:14 AM
Ervis Meta
Ervis Meta - avatar
- 1
Ervis Meta It is not executing your code. I don't know why. This is last code project in Python for begginers.
4th Jun 2021, 10:24 AM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
- 1
def search(word, text): text = input() word = input() if word in text: return text print("Word found") if word not in text: return text print("Word not found") ## In this code 3 test cases are correct and 3 test cases are wrong.
4th Jun 2021, 10:45 AM
Siddhartha Kushwaha
Siddhartha Kushwaha - avatar
- 1
No problem 😃👌
4th Jun 2021, 3:20 PM
Ervis Meta
Ervis Meta - avatar