All problems
Mention Extraction
Problem
Extract user mentions from text with the pattern @ followed by letters, digits, or underscores.
Return the handles without the @ sign, keeping only the first occurrence of each handle in document order.
Hint
findall returns matches in order; drop the leading @ and deduplicate.
Test cases
case 1
in: ["hey @alice and @bob"]
expected: ["alice","bob"]
case 2
in: ["@a @a @b"]
expected: ["a","b"]
case 3
in: ["no mentions"]
expected: []
case 4
in: ["email a@b.com"]
expected: ["b"]
Starter codePython
import re
def mention_extraction(text):
# Your code here
pass4 test cases · run your code against them in the editor