Question

def add_mention_exclusive(valid_tweet: str, tweet_word: str) -> str: Return if the potential tweet is valid, the original t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 def add_mention_exclusive (valid_tweet, tweet_word): Python 3.7.4 (default, Jul 9 [GCC 6.3.0 20170516] on linux Go Raptors!

def add_mention_exclusive(valid_tweet, tweet_word):

        if '@' + tweet_word in valid_tweet:
                return valid_tweet
        else:
                return valid_tweet + ' @' + tweet_word

print(add_mention_exclusive('Go Raptors!', 'Raptors'))
print(add_mention_exclusive('Go @Raptors!', 'Raptors'))
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.

Add a comment
Know the answer?
Add Answer to:
def add_mention_exclusive(valid_tweet: str, tweet_word: str) -> str: ""Return if the potential tweet is valid, the original...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • def contains_hashtag(valid_tweet: str, tweet_word:str) -> bool: '''Return True if the valid tweet contains the tweet word,...

    def contains_hashtag(valid_tweet: str, tweet_word:str) -> bool: '''Return True if the valid tweet contains the tweet word, with a hashtag at the beginning. Tweet can contain multiple tweet words. >>>contains_hashtag('I like #csc108', 'csc108') True >>>contains_hashtag('I like #csc108', 'csc') False >>>contains_hashtag('I like #csc108, #mat137, and #phl101', 'csc108') True pls finish this function by using python string method(do not use advance methods)

  • COMPLETE THE FOLLOWING QUESTION def find_favourite_artist(filename: str) -> str: ''' Return the name of the artist...

    COMPLETE THE FOLLOWING QUESTION def find_favourite_artist(filename: str) -> str: ''' Return the name of the artist that occurs most frequently in the song file of the given filename. If there are more than one artists that occur most frequently, just return any of them. Note: Feel free to create helper functions for this if you need to. Hint: You may want to use the "sorted" function. ''' pass THE SONG FILE IS: Title, Singer, Release Year Let it go, Idina...

  • ##8. A program contains the following function definition: ##def cube(num): ##return num * num * num...

    ##8. A program contains the following function definition: ##def cube(num): ##return num * num * num ##Write a statement that passes the value 4 to this function and assigns its return value ##to the variable result. ##9. Write a function named times_ten that accepts a number as an argument. When the ##function is called, it should return the value of its argument multiplied times 10. ##10. Write a function named is_valid_length that accepts a string and an integer as ##arguments....

  • def analyze_word(word, pos_words, neg_words): ''' (str, list, list) -> int    Given a word, a list...

    def analyze_word(word, pos_words, neg_words): ''' (str, list, list) -> int    Given a word, a list of positive words (all in lowercase), and a list of negative words (all in lowercase), return whether or not the word is positive, negative or neutral. For a positive word, return 1. For a negative word, return -1. For a neutral word (one that does not appear in either the negative words list nor the positive words list), return 0. >>> ("happy", ['happy', 'love'],...

  • This CSIS 9 Python. Java Python Warmup-2 > string_times prev next | chance Given a string...

    This CSIS 9 Python. Java Python Warmup-2 > string_times prev next | chance Given a string and a non-negative int n, return a larger string that is n copies of the original string. string_times('Hi', 2) – 'HiHi' string_times('Hi', 3) - 'HiHiHi' string_times('Hi', 1) – 'Hi' Solution: Go Save, Compile, Run (ctrl-enter) Show Solution def string_times (str, n): def string_times(str, n): result = "" for i in range(n): # range(n) is [0, 1, 2, .... n-1] result = result + str...

  • In Python 3 only please. A simple function that will be used on a file. commonpair(str)...

    In Python 3 only please. A simple function that will be used on a file. commonpair(str) – Takes a single string argument, representing the first word. This function should return the word that most frequently followed the given argument word (or one of, in case of ties). If the argument word does not appear in the text at all, or is never followed by another word (i.e., is the last word in the file), this function should return None. I...

  • def average_word_length(string): num_words = 0 if not type(string)==str: return "Not a string" if not "A" or...

    def average_word_length(string): num_words = 0 if not type(string)==str: return "Not a string" if not "A" or not "B" or not "C" or not "D" or not "E" or not "F" or not "G" or not "H" or not "I" or not "J"\ or not "K" or not "L" or not "M" or not "N" or not "O" or not "P" or not "Q" or not "R" or not "S" or not "T"\ or not "U" or not "V" or not...

  • Just using print not return Imodify this function to not only return but also keep printing...

    Just using print not return Imodify this function to not only return but also keep printing def reverseoigits num): Reverse the digits of an Integer using recursion Return a string that contains the reversed number Returns None lt nu . 1 num < 0 return None num >= 0 and num < 9: return str(num) return str(num110) +reverseDigits (int(num/10)) RESTART: /cs/student/rkumaran/Labos pypy = >>>reversedigits(0) >>> reverse igits (6) >>> reverseDigits (52) >>reverseDigits (5328) >>> reverseDigits (-5328) >>> a = reversedioits/5328...

  • ef count_common_occurrences(word1, word2): (str, str) -> int Given two strings, word1 and word2, return how many...

    ef count_common_occurrences(word1, word2): (str, str) -> int Given two strings, word1 and word2, return how many characters in word1 are letters that also occur in word2. You can assume all characters in the given string are lowercase. Also, spaces do not count as a common character. Algorithm: - Go through each character in word1, one by one. If this character occurs in word2, then add 1 to the count. Return total count after you're done going through the characters. >...

  • 2. This question is about processing strings 2.1 [4 marks] Given a string str, we can...

    2. This question is about processing strings 2.1 [4 marks] Given a string str, we can calculate a checksum of the string by summing up the ASCII codes of the characters in the string. For example, the checksum of a string "apple" is 530, which equals to 'a' + 'p' + 'p' + 'l' + 'e' = 97 + 112 + 112 + 108 + 101. Write a function int calculate_checksum(char str[] that calculates and returns the checksum of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT