Question: I am learning python through "*Learn Python The Hard Way*" by *Zed A Shaw*.

I am currently confused by this question

> 
> Make some new relationships that are lists and dictionaries so you can also have "has-many" relationships.
> 
> 
> 

Can anyone explain and give me some examples?

**EDIT**
This is the link
[Exercise 42](https://learnpythonthehardway.org/book/ex42.html)

Answer: 
A [*has-many*](https://loopback.io/doc/en/lb2/HasMany-relations.html) relationship *X* to *Y* usually means that every element in *X* is associated with many (zero or more) elements in *Y*. So you can construct a **dictionary that maps elements of *X* to a *list* of *Y***.

For instance if we want to know what a person (*X*) owns (*Y*):

```
{
 'Alice': ['laptop','house'],
 'Bob':['Gameboy'],
 'Chris':['pony'],
 'Plankton':[]
}

```

So here (1) Alice owns a laptop and a house. (2) Bob owns only a gameboy and (3) Chris owns a pony and (4) Plankton owns nothing at all.
to contextualize:
in exercise 42 of the book Learn Python The Hard Way we are studing about classes and objects.
The autor Zed Shaw give us the code below and we have to make comments for the classes and objects.
We have to use "is-a" when we talk about objects and classes being related to each other by a class relationship. We use 'has-a' when we talk about objects and classes that are related only because they "reference" each other.

So, the code with my comments:

```
## Animal is-a object
class Animal(object):
    pass

## Dog is-a Animal
class Dog(Animal):

    def __init__(self,name):
        ## Dog has-a name
        self.name = name

## Cat is-a Animal
class Cat(Animal):

    def __init__(self, name):
        ## Cat has-a name
        self.name = name

## Person is-a object
class Person(object):

    def __init__(self, name):
        ## Person has-a name
        self.name = name

        ## Person has-a pet of some kind
        self.pet = None

## Employee is-a Person
class Employee(Person):

    def __init__(self, name, salary):
        ## Employee has-a name (coming from Person, because Employee is-a Person)
        super(Employee, self).__init__(name)
        ## Employee has-a salary
        self.salary = salary

## Fish is-a object
class Fish(object):
    pass

## Salmon is-a Fish
class Salmon(Fish):
    pass

## Kalibut is-a Fish:
class Halibut(Fish):
    pass

## Rover is-a Dog
rover = Dog("Rover")

## Satan is-a Cat
satan = Cat("Satan")

## Mary is-a Person
mary = Person("Mary")

## Mary has-a pet "Satan"
mary.pet = satan

# Frank is-a Employee that has-a salary
frank = Employee("Frank", 120000)

## Frank has-a pet "Rover"
frank.pet = rover

## flipper is-a fish
flipper = Fish()

## crouse is-a Salmon
crouse = Salmon()

## harry is-a Halibut
harry = Halibut

```

In one of the study drills the autor tell to us "Make some new relationships that are lists and dictionaries so you can also have “has-many” relationships."

So, for exemple:

```
## Mary is-a Person
mary = Person("Mary")

## Mary has-a pet "Santan"
mary.pet = santan

```

But Mary can have more than one pet, right? So:

```
## Mary has-many pets: "Santan" and "Rover"
mary.pet = [santan, rover]  # has-many with list

```

Or, you can use a dictionary, so:

```
## Mary has-many pets: Satan (is-a cat) and rover (is a dog)
mary.pet =  {'cat': satan, 'dog': rover}  # has-many with dictionary

```

Now everyone can understand the context of the question.