title: Python - High order function - make_fair_dice
body: <p>I am working on a project. I need to create dice. And I have a solution below:</p>
  <pre><code>from random import randint
  
  def make_fair_dice(sides):
      &quot;&quot;&quot;Return a die that returns 1 to SIDES with equal chance.&quot;&quot;&quot;
      assert type(sides) == int and sides &gt;= 1, 'Illegal value for sides'
      def dice():
          return randint(1,sides)
      return dice
  
  four_sided = make_fair_dice(4)
  six_sided = make_fair_dice(6)
  </code></pre>
  <p>I don't understand why the solution created a inner function dice(). I think it's not necessary. But I knew I probably missed a important concept. As always code is not hard but concept.</p>