0

I am struggling on completing this zybook challenge activity and I don't know what else

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.

Willie Finch
  • 11
  • 1
  • 1
  • 2
  • 1
    This question can be made better by adding details. Please have a look at https://stackoverflow.com/help/how-to-ask and edit your post accordingly. – Rishabh Kumar Feb 24 '21 at 04:26
  • Does this answer your question? [Does Python have a string 'contains' substring method?](https://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method) – Tomerikoo Feb 27 '21 at 16:28

3 Answers3

2

What this is asking you to do is print "LOL means laughing out loud" if LOL is in the tweet (if 'LOL' in user_tweet:).

If the tweet does not have LOL (else:), print 'No abbreviation.'

This gives you the if-else statement:

if 'LOL' in user_tweet:
    print('LOL means laughing out loud.')
else:
   print('No abbreviation.')
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Abbie Shaw
  • 21
  • 1
0

enter code hereuser_tweet = input() if(user_tweet.find('LOL') != -1): print('LOL means laughing out loud.') else: print('No abbreviation.')

Using the find function works as well. The find function is searching user_tweet for string placement index != (not equal) to -1. The find function returns the index of the first occurrence of item x in the string, else returns -1.

-1

if 'LOL' in user_tweet:

is the correct code for here

if LOL is in the the tweet it will output the abbreviation if not it will say not abbreviation.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Blue Robin Mar 17 '23 at 00:07