0

Whats the problem with this code

import re pattern = r"([\w\.-]+)@([\w\.-]+)(\.[\w\.]+)" str = "Please contact the following email for assistance info@sololearn.com, okekeifeomachristiana@gmail.com, okekeraphaelblaze@gmail.com" match = re.findall(pattern, str) if match: print(match.groups())

26th Dec 2019, 10:33 AM
okeke martin
2 Réponses
+ 2
Replace: print(match.groups()) With: print(match)
27th Dec 2019, 1:38 AM
John Wells
John Wells - avatar
0
The "match" in your code is a list of matches, not a match object, so it doesn't have the groups() method. If you want to extract the email addresses, you'll have to modify the code a bit more. Here are two ways to do it: https://code.sololearn.com/cu18lenBYnoZ/?ref=app https://code.sololearn.com/cK2l8ddttMIr/?ref=app
28th Dec 2019, 8:31 AM
Njeri
Njeri - avatar