我在 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.')
这有效:使用输入在您的情况下没有用。
user_tweet = 'I was LOL during the whole movie!'
if'LOL' in user_tweet :
print('LOL means laughing out loud.')
else:
print('No abbreviation.')
输入允许获取用户输入。
我拿走了你的 if 语句并将其替换为
if 'lol' in user_tweet.strip().lower():
它对我有用
如果 user_tweet 中存在“LOL”:
这对我有用