Hi everyone,
I struck with this code for few day , please help me and thanks in advance .

Write the class AddressBook so the following code works:

c = AddressBook()

c.add(name='ynon', email='ynon@ynonperek.com', likes='red')
c.add(name='bob', email='bob@gmail.com', likes='blue')
c.add(name='ynon', email='ynon@gmail.com', likes='blue')

c.find_by(name='ynon')
# returns:
# [
#   {'name': 'ynon', 'email': 'ynon@ynonperek.com', 'likes': 'red'},
#   {'name': 'ynon', 'email': 'ynon@gmail.com', 'likes': 'blue}
# ]

c.find_by(likes='blue)
# returns:
# [
#   { 'name': 'bob', 'email': 'bob@gmail.com', 'likes': 'blue' },
#   {'name': 'ynon', 'email': 'ynon@gmail.com', 'likes': 'blue'}
# ]

Show us what you've tried so far.

Here's an issue. Code works as I read above. The issue is that I would be guessing what the code was supposed to do. As code can work incorrectly but work you need to add more about what your specification so that others can comment.

We know that some students dump homework here and there is much written about this behavior. It's also why you don't see folk handing you working code back most of the time. A good reply after you tell what the function is supposed to do is usually in psuedocode that you turn into real working code.

Also, read https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.