title: OOP - instance of a class is created, a different class should be created , an array stores every new instance created
body: <p>I am having trouble understanding the following instructions in an exercise:</p>
  <ol>
  <li><p>Create another class Location which has two properties called coordinate and name.</p>
  </li>
  <li><p><strong>Each time an instance of Location is created,
  a class Coordinate should be created that gets passed in the coordinates that should be given as arguments when creating Location</strong>.</p>
  </li>
  <li><p>Further, you should create a return_location method that returns the name of the location.</p>
  </li>
  <li><p><strong>An array locations which is a class variable of Location stores every Location that is created.</strong></p>
  </li>
  </ol>
  <p>So far I have this:</p>
  <pre><code>class Coordinate:
      def __init__(self,latitude,longitude):
          self.latitude = latitude
          self.longitude = longitude
      def return_coord(self):
          return self.latitude, self.longitude
  
  class Location:
    locations = [0]
  
    def __init__(self,coordinate,name):
      self.coordinate = coordinate 
      self.name = name 
      locations.append(self) #store every location created on the array locations  
  
    def return_location():
      return self.name
  </code></pre>
  <p>But I am not sure if I am indeed doing the second step correctly
  and when trying to do the 4th step it shows me the error: <code>NameError: Name ´locations´ is not defined, did you mean Location?</code></p>