+ 6
search engine challenge
what is wrong in my code,I am not getting right answer. Pls. help me out text = input() word = input() def search(text,Word): if Word in text: print("Word found") else: print("Word not found") search(text,Word)
19 ответов
+ 18
text = input()
word = input()
def search(text,word):
if word in text:
return("Word found")
else:
return("Word not found")
print(search(text,word))
maybey like thes
+ 7
Sachin
There are two problems
1 - Indentation
2 - you are taking input as word but passed in function as Word.
So try this
text = input()
word = input()
def search(text, word):
if word in text:
print("Word found")
else:
print("Word not found")
search(text, word)
+ 5
No one likes homework, but your math teacher has given you an assignment to find the sum of the first N numbers.
Let’s save some time by creating a program to do the calculation for you!
Take a number N as input and output the sum of all numbers from 1 to N (including N).
Sample Input
100
Sample Output
5050
Explanation: The sum of all numbers from 1 to 100 is equal to 5050.
+ 3
Sachin
Why did you write return? Why you don't just call function without return?
+ 3
I know it and i completed it
This is how you need to do it
Only 6 lines simple
text = input()
word = input()
if word in text:
print("Word found")
elif word not in text:
print("Word not found")
+ 2
text = input()
word = input()
def search(text, word):
#for i in word:
if word in text:
a ="Word found"
return a
else:
b = "Word not found"
return b
print(search(text, word))
#not at all!
+ 2
def search(text, word):
# look whether the word is in the text
if word in text:
print('Word found')
else:
print('Word not found')
text = input()
word = input()
search(text, word)
+ 1
No need to return search(text,Word) otherwise it will become recursive function.Just return.
And also you forgot to call the function:
https://code.sololearn.com/cu5f8ltJeiJp/?ref=app
+ 1
The future is now thanks to science
No need to write return if you are not returning any value and just printing value.
+ 1
"""If you use print() in the function, it will print when word is found and then test it twice so it produces a "word found" and "none", or it produces "word not found" and "none" Instead of using print inside the function, use return. """
text = input()
word = input()
def search(x, y):
if y in x:
return 'Word found'
else:
return 'Word not found'
print(search(text, word))
0
By mistake,but without return there is no output
0
The future is now thanks to science
I never heard it is good to write without any reason.
0
Feel like stupid. Tried to find word in search ((( not in text(((
0
text = input()
word = input()
def search(text, word):
#for i in word:
if word in text:
a ="Word found"
return a
else:
b = "Word not found"
return b
print(search(text, word))
0
This worked fine
#your code goes here
text = input()
word = input()
def search (text, word):
if word in text:
print ("Word found")
else:
print ("Word not found")
search(text, word)
#remove the last print, 100%working
0
text = input()
word = input()
def search(text, word):
if word in text:
print("Word found")
else:
print("Word not found")
search(text, word)
This worked for me 100%!!
0
def search(text, word):
x="Word found"
y="Word not found"
if word in text:
return x
else :
return y
text = input()
word = input()
print(search(text, word))
Works for sure..!
- 1
the most simple code:
text=input('Enter the text: ')
word=input('Enter the word you want to search: ')
t=text.split()
c=0
for i in t:
if(i==word):
c+=1
if(c!=0):
print('found')
else:
print('not found')
- 2
Hey, help me out pls. I know that this way of solving is overcomplicated, but i wonder why this code not working? if you run it, it will additoinally print "None" on the new line. And i dont get were from it appeared?
def search(text, word):
if text.count(word) >=1:
return(print("Word found"))
else:
return(print("Word not found"))
text = input()
word = input()
print(search(text, word))