Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Regular Expressions in Python Introduction to Regular Expressions Email

please help me. i have run this code in jupyter notebook and it works.

please help me. i have run this code in jupyter notebook and it works.

sets_email.py
import re

# Example:
# >>> find_email("kenneth.love@teamtreehouse.com, @support, ryan@teamtreehouse.com, test+case@example.co.uk")
# ['kenneth@teamtreehouse.com', 'ryan@teamtreehouse.com', 'test@example.co.uk']

def find_emails(string):
    pattern = r"(?!.*\.\.)[\w.\-#!$%&'*+\/=?^_`{}|~]{1,35}@[\w.\-]+\.[a-zA-Z]{2,15}"
    x = re.findall(pattern,string)
    print(x)

find_emails("kenneth.love@teamtreehouse.com, @support, ryan@teamtreehouse.com, test+case@example.co.uk")

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Em Noble

Yes, the code will work, but it is not what the challenge is asking for exactly.

The challenge asks you to create a function and Return the addresses, but you are printing them. Once you change that up, the task will pass. (Also, the challenge does not ask you to call the function.)

You'll need to remember that Challenges are very specific and extremely picky when it comes to the instructions. Even a little deviation from them will often cause the task to receive the "Bummer!" message. So, even though it would be syntactically correct, if it's not exactly what the instructions ask for, it may not pass.

Keep Coding! :) :dizzy: