title: How do I initialize an instance of one class within another (Im new sorry)
body: <p>Okay I'm making a fake amusement park ride, I have a tram class that just has a max # of stops for the init paramater, and a move method that adds 1 to the current station. I now have a park class that SHOULD basically print this in a nice format, but I'm getting stuck since I need to initialize my tram within the park init method.</p>
  <p>Tram class:</p>
  <pre><code>class Tram:
      def __init__(self, m):
          self.m = m
      
      station = 1
      def move(self):
          Tram.station += 1
  
      def __str__(self):
          return &quot;The Tram is currently at station {} out of {}&quot;.format(Tram.station, self.m)
  </code></pre>
  <p>Now the Park class:</p>
  <pre><code>class Park:
      import Tram as Tram
      def __init__(self, m, lst):
          self.m = m
          self.lst = lst
          
  
      def __str__(self):
          print('------------------------------------------------------------')
          print(' Station                  Customer                   Tram   ')
          for i in range(self.m, 1, -1):
              for j in self.lst:
  
                  print('    {}                        {}                    '.format(i))
  </code></pre>
  <p>It's not finished so ignore the str part, I just need help on how I can create an instance of a tram inside the park init, like so:</p>
  <pre><code>class Park:
      import Tram as Tram
      def __init__(self, m, lst):
          self.m = m
          self.lst = lst
          self.tram = Tram(self.m/m) &lt;- SOMETHING LIKE THAT or:
          tram = Tram(self.m/m)
  </code></pre>
  <p>Please help, this seems like a really dumb question but I'd appreciate an explanation too, I'm kinda new to classes. Also here's my end goal.</p>
  <pre><code>&gt;&gt; P = Park.Park(3, [[1, 2], [3, 1]])
  &gt;&gt; print(P)
  
  
  ------------------------------------------------------------
   Station                  Customer                   Tram   
  ------------------------------------------------------------
      3                        2                    
  ------------------------------------------------------------
      2                                             
  ------------------------------------------------------------
      1                        1                       *T*    
  ------------------------------------------------------------
  </code></pre>