zybooks 2.10.1 查找缩写

问题描述 投票:0回答:3

我在 zybooks 中陷入了这个挑战活动。如果 user_tweet 包含“LOL”,则要求完成 if-else 语句以打印“LOL 意味着大声笑”。

带有输入的示例输出:“整部电影我都笑了!” LOL 的意思是大声笑。

这是我认为可行的代码,但我认为我缺少了一块:

user_tweet = input()
user_tweet = input('I was LOL during the whole movie!')
print()
if'LOL' in user_tweet :
    print('LOL means laughing out loud.')
else:
    print('No abbreviation.')
python if-statement
3个回答
0
投票

这有效:使用输入在您的情况下没有用。

user_tweet = 'I was LOL during the whole movie!'
if'LOL' in user_tweet :
    print('LOL means laughing out loud.')
else:
    print('No abbreviation.')

输入允许获取用户输入。


0
投票

我拿走了你的 if 语句并将其替换为

if 'lol' in user_tweet.strip().lower(): 

它对我有用


0
投票

如果 user_tweet 中存在“LOL”:

这对我有用

© www.soinside.com 2019 - 2024. All rights reserved.