Search engine -python challenge | Sololearn: Learn to code for FREE!

-3

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!!

2/2/2021 12:04:24 PM

THIRU KUMARAN T R

24 Answers

New Answer

+9

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)

+6

#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))

+3

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

+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

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(): if word in text: print('Word found') return else: print('Word not found') search()

+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

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))

0

Is there any other shorter approach

0

Arxalier Thanks bro I've learned some of the expressions in Regex .Soon will try to implement myself in upcoming projects !!

0

Arnav Singh Kainth Thank you bro!!

0

KSnamAce No Need Bro. I Will Always Help You. Also, Can you please follow me.

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))

0

i just completed python basics and here is my certificate

0

i use this 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

text = input() word = input() def search(text,word): if word in text : return ("Word found") else: return ("Word not found") print(search(text, word))

0

My solution: text = input() word = input() def search(text, word): if word in text: return "Word found" else: return "Word not found" print(search(text, word))

0

All these cannot run, how is it created? Asking for somebody.

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))