-1

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'}
# ]

Edited by Kushmitha

3
Contributors
2
Replies
41
Views
1 Week
Discussion Span
Last Post by rproffitt
0

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

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.