Email Extractor
Given a line of text containing several email addresses, use re.findall() to extract all of them.
Approach: the pattern [\w.-]+@[\w.-]+\.\w+ matches the username part, the @, the domain, and the extension.
Input: One line: a sentence containing zero or more email addresses.
Output: One line: every email address found, printed as a Python list, in the order they appear.
Contact aditi@test.com or support@company.org for help
['aditi@test.com', 'support@company.org']
- 1 <= length of text <= 1000
Hint 1
[\w.-]+ matches one or more letters/digits/dots/hyphens — useful for both the username and the domain part.
Hint 2
The full pattern is r"[\w.-]+@[\w.-]+\.\w+".
Hint 3
re.findall() already returns a list, ready to print directly.
The pattern [\w.-]+@[\w.-]+\.\w+ matches: one or more "word" characters/dots/hyphens (the username), an @, another run of word characters/dots/hyphens (the domain), a literal dot, and a final run of word characters (the extension). re.findall() returns every non-overlapping match as a list, in the order they appear in the text.