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 Compiling and Loops

boi
boi
8,670 Points

Extra credit submission

A quick extra credit solution.

import re

from address_book import line, data


class Person(list):
  def __init__(self):
    for match in line.finditer(data):
      self.append(match.groupdict())


class Address_Book:
  def __init__(self, arg):
    for x in Person():
      for key, value in x.items():
        if value == arg:
          for key, value in x.items():
            print("{}: {}".format(key, value))


info = input("Enter person name: ").capitalize()
person = Address_Book(info)

Disclaimer This solution is not absolute nor the right one. It carries loopholes, unpolished lines, and a sh*t ton of bugs. I just needed to make it work ASAP and move on. If someone is crazy enough to fix it or use it, do it without question.