Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Regular Expressions in Python Introduction to Regular Expressions Email

Em Noble
Em Noble
1,894 Points

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.

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)

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

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,541 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: