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 trialMohsen Qaddoura
22,237 PointsAnswer to challenge not getting any output
here's my code
import re
string = '''Love, Kenneth, kenneth+challenge@teamtreehouse.com, 555-555-5555, @kennethlove
Chalkley, Andrew, andrew@teamtreehouse.co.uk, 555-555-5556, @chalkers
McFarland, Dave, dave.mcfarland@teamtreehouse.com, 555-555-5557, @davemcfarland
Kesten, Joy, joy@teamtreehouse.com, 555-555-5558, @joykesten'''
contacts = re.search (r'''
^(?P<email>[-\w\d.+]+@[-\w\d.]+)\t # Email
(?P<Phone>d{3}-\d{3}-\d{4})\t$''', string, re.X|re.M)
import re
string = '''Love, Kenneth, kenneth+challenge@teamtreehouse.com, 555-555-5555, @kennethlove
Chalkley, Andrew, andrew@teamtreehouse.co.uk, 555-555-5556, @chalkers
McFarland, Dave, dave.mcfarland@teamtreehouse.com, 555-555-5557, @davemcfarland
Kesten, Joy, joy@teamtreehouse.com, 555-555-5558, @joykesten'''
Kenneth Love
Treehouse Guest TeacherDon't include the comma or the space. They're not part of the email address or the phone number.
1 Answer
Kenneth Love
Treehouse Guest TeacherThere aren't any tab characters in the code challenge, so you'll want to catch \s
instead.
Mohsen Qaddoura
22,237 PointsI've completed the course. Thank you .
For some reason I could not mark or comment on your latest answer as they both became unavailable after I removed an initial comment!
Waiting for more exciting Python courses :)
Mohsen Qaddoura
22,237 PointsMohsen Qaddoura
22,237 PointsI still did not pass this challenge, and the word length one which I'll post in a separate question, though I went successfully though all the rest of the course.
Here is my modified code as per your kind answer:
Now I'm getting this error message:
Bummer! Didn't get the right content in your groups. Email: "kenneth+challenge@teamtreehouse.com, ", Phone: "555-555-5555, ".
I'm assuming it's the trailing comma at the end of each group content or just the phone group causing this error, I have tried many various modification to my code but none of the ones that gave a regex search object got rid of the trailing comma. I'm not sure what else could be the required groups content.