title: Why is "None" printed after my function's output?
body: <p>I tried writing this code:</p>
  <pre><code>def smaller(x, y):
      if x &gt; y:
          print(y) 
      else:
          print(x) 
  
  print(smaller(2, 3))
  </code></pre>
  <p>I got this result:</p>
  <pre><code>&gt;&gt;&gt;
  2
  None
  </code></pre>
  <p>Where did the <code>None</code> come from? What does it mean?</p>
  <hr />
  <p><sub>The accepted answer explains the importance of <code>return</code>ing a value from the function, rather than <code>print</code>ing it. See <a href="https://stackoverflow.com/questions/7129285">What is the purpose of the return statement? How is it different from printing?</a> for more information.</sub></p>
  <p><sub>To understand the <code>None</code> result itself, see <a href="https://stackoverflow.com/questions/21095654/what-is-a-nonetype-object">What is a &#39;NoneType&#39; object?</a>.</sub></p>
  <p><sub>If you are <code>print</code>ing inside the function in order to see multiple values, it may be better to instead <em>collect</em> those values so that they can be printed by the calling code. See <a href="https://stackoverflow.com/questions/44564414/">How can I use `return` to get back multiple values from a for loop? Can I put them in a list?</a> for details.</sub></p>