如何在python(简单搜索引擎)中检查单词是否在短语中

如何在python(简单搜索引擎)中检查单词是否在短语中,python,python-3.x,Python,Python 3.x,好的,我的代码有一些问题,这是一个简单的python搜索引擎,用户可以通过它输入一个句子和一个单词。如果单词在句子中,则代码将输出“word found”,如果单词未找到,则应打印“word not found” 这是我的密码: text = input() word = input() def wrong(text, word): print("Word not found") wrong(text, word) def right(text, word

好的,我的代码有一些问题,这是一个简单的python搜索引擎,用户可以通过它输入一个句子和一个单词。如果单词在句子中,则代码将输出“word found”,如果单词未找到,则应打印“word not found”

这是我的密码:

text = input()
word = input()

def wrong(text, word):
    print("Word not found")    
wrong(text, word)

def right(text, word):
    print("Word found")
right(text, word)

def check(right, wrong):
    if text.index == word:
        return right
    elif text.index != word:
        return wrong
check(right, wrong)


因此,作为输出,我得到的是两个响应,而不是一个。请帮帮我。

你在找类似的东西吗?:

a = 'some word'
b = 'some'

if b in a:
  print('yes')
else:
  print('no')

如果文本中有单词:。。。否则:…
在定义它们之后,您正在无条件地调用
错误的
正确的
。因此,是的,两者都将始终打印。是一个你必须调用的函数,而不是用来比较字符串的函数。是的,我还没有试过,让我看看是的,它是完全功能的。谢谢如果答案正确,请不要忘记将其标记为正确答案
text = input('input text: ')
word = input('input a word: ')

if word in text:
    print('Word found!')
else:
    print('Word not found')