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 trialJ R
Courses Plus Student 12,168 PointsGetting incorrect info in console at the end of video. Also - Bug for 'Get Help' on chrome version of website.
This is the code I have below. I have referenced Kenneth's code several times and caught 2 errors but can not for the life of me find the last one.
line = re.search(r'''
^(?P<name>[-\w ]*,\s[-\w ]+)\t
(?P<email>[-\w\d.+]+@[-\w\d.]+)\t
(?P<phone>\(?\d{3}\)?-?\s?\d{3}-\d{4})?\t
(?P<job>[\w\s]+,\s[\w\s.]+)\t?
(?P<twitter>@[\w\d]+)?$
''', data, re.X|re.M)
print(line)
print(line.groupdict())
Following is the result I get from the console after running my script:
<_sre.SRE_Match object; span=(0, 86), match='Love, Kenneth\tkenneth@teamtreehouse.com\t(555) 5>
{'name': 'Love, Kenneth', 'email': 'kenneth@teamtreehouse.com', 'phone': '(555) 555-5555', 'job': 'Teacher, Treehouse\t', 'twitter': '@kennethlove'}
From what I can tell, his result goes : Name, email, job, twitter, phone. And my result goes : Name, email, phone, job, twitter. My result is in the same order as the code, but his goes out of order and puts the phone category at the end.
Is there something I am missing which accounts for this mix up? Or is it an aspect of regex / dictionaries?
BUG - When clicking on 'Get Help' button on pages with videos, it starts playing or resumes the video. Very minor but still thought I would point it out for some "Whose line is it anyways?" type points.
1 Answer
Steven Parker
231,248 PointsThis is not an aspect of regex, but of dictionaries in general. Dictionaries are orderless collections, and the order items appear in the output is neither significant nor should it be relied on to remain consistent.
Your other observation sounds like a legitimate bug. You may want to report it directly to the staff as described on the Support page. I don't think it carries any points, but you may get the "special Exterminator badge".