'zybooks 2.10.1 Finding abbreviation
I'm stuck on this challenge activity in zybooks. It's asking Complete the if-else statement to print 'LOL means laughing out loud' if user_tweet contains 'LOL'.
Sample output with input: 'I was LOL during the whole movie!' LOL means laughing out loud.
This is the code I thought would work, but I think I'm missing a piece:
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.')
Solution 1:[1]
This works: using input is not usefull in your case.
user_tweet = 'I was LOL during the whole movie!'
if'LOL' in user_tweet :
print('LOL means laughing out loud.')
else:
print('No abbreviation.')
Input allows to get user input.
Solution 2:[2]
I took your if statement and replaced it with
if 'lol' in user_tweet.strip().lower():
and it worked for me
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Peter Csala |