小编Wad*_*dbo的帖子

检查字符串是否在列表中

我见过很多此类问题的解决方案,但我找不到我正在寻找的解决方案。

例如:

text = ['hi', 'hello', 'hey']
user_input = input('Enter something: ')

for word in user_input:
    if word in text:
        print('Hi')
    else:
        print('Bye')
Run Code Online (Sandbox Code Playgroud)

如果是user_input“嗨,那里”,它会给我回复

Bye
Bye
Bye
Bye
Bye
Bye
Bye
Bye
Run Code Online (Sandbox Code Playgroud)

如何检查user_input列表(文本)中是否至少有一个单词?

python input list

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

input ×1

list ×1

python ×1