0
Search engine -python challenge
https://code.sololearn.com/cQsvfP3sGu8y/?ref=app Aim of the program is to check for a word in a given sentence and print found if it's present else not found I'm not sure where I messed up pls take a look guys!!
31 Respostas
+ 28
#The Easiest Way To Solve It
text = input()
word = input()
def search(text, word):
if word in text:
return("Word found")
else:
return("Word not found")
print(search(text, word))
+ 14
Search engine Python challenge
text = input()
Word = input()
def search(text,Word):
if Word in text:
print("Word found")
else:
print("Word not found")
search(text,Word)
+ 4
If yu wanna perform addition on global variable like c you need to access it using global keyword to change it's value .
c=0
def search(text,word):
t=text.split()
for i in t:
if i==word:
global c
c+=1
text = input()
word = input()
search(text,word)
if c==0:
print("Word not found")
else:
print("word found")
+ 3
[Additional answer]
Yes, here is a possible shorter approach:
def search(text, word):
return word in text
text = input().split()
word = input()
x = search(text, word)
if x:
print("Word found)
else:
print("Word not found")
- - - - - - - - - - - - - - - - -
Or just simply like this (my ver.)
text = input()
print("Word found" if input() in text else "Word not found")
https://code.sololearn.com/c0DH2TKULpLK/?ref=app
https://code.sololearn.com/cbukdYd3H3XR/?ref=app
+ 3
text = input()
word = input()
def search():
if word in text:
print('Word found')
return
else:
print('Word not found')
search()
+ 3
Maybe shortest way?
def search(text, word):
if word in text:
print("Word found")
else:
print("Word not found")
search(input(), input())
+ 2
Arnav Singh Kainth
Thank you bro!!
+ 2
Try don't copy it !!!
def search(text, word):
if word in text:
return("Word found")
else:
return("Word not found")
text = input()
word = input()
print(search(text, word))
+ 1
Is there any other shorter approach
+ 1
Cyan Thank you bro!!
+ 1
Also I'd recommend learning Regular Expressions (RegEx) if you're interested in getting into these types of projects. RegEx helps a lot with string identification and it's really handy
+ 1
Arxalier Thanks bro I've learned some of the expressions in Regex .Soon will try to implement myself in upcoming projects !!
+ 1
KSnamAce No Need Bro. I Will Always Help You. Also, Can you please follow me.
+ 1
text=input()
word=input()
def search(text,word):
c=0
array=text.split()
for i in array:
if i==word:
c+=1
else:
c+=0
return c
def compare(c):
if c>=1:
print('Word found')
else:
print('Word not found')
compare(search(text,word))
+ 1
text = input()
word = input()
def search(text,word):
if word in text :
return ("Word found")
else:
return ("Word not found")
print(search(text, word))
+ 1
text = input()
Word = input()
def search(text,Word):
if Word in text:
print("Word found")
else:
print("Word not found")
search(text,Word)
+ 1
why yall so big brain
+ 1
def search(text):
if word in text:
return("Word found")
else:
return("Word not found")
text = input()
word = input()
print(search(text))
+ 1
Easiest for me:
text = input()
word = input()
if word in text:
print("Word found")
else:
print("Word not found")
0
text = input()
word = input()
def search(text, word):
if word in text:
return "Word found"
else:
return "Word not found"
print(search(text, word))