Nov-24-2019, 03:15 PM
How can I extract email addresses from a string and store them in a list? The following code produces the desired output when printed in the for loop, but I am not sure how to store them in one accessible list.
text = 'Emails: [email protected], [email protected], [email protected]' text = text.split() for word in text: if '@' in word: emails = word emails = emails.replace(',', '') emails = emails.split() print(emails)
Output:['[email protected]']
['[email protected]']
['[email protected]']