title: How is returning the output of a function different from printing it?
body: <p>In my previous <a href="https://stackoverflow.com/questions/746774/basic-python-quick-question-regarding-calling-a-function">question</a>, Andrew Jaffe <a href="https://stackoverflow.com/a/746844/17242583">writes</a>:</p>
  <blockquote>
  <p>In addition to all of the other hints and tips, I think you're missing something crucial: your functions actually need to return something.
  When you create <code>autoparts()</code> or <code>splittext()</code>, the idea is that this will be a function that you can call, and it can (and should) give something back.
  Once you figure out the output that you want your function to have, you need to put it in a <code>return</code> statement.</p>
  </blockquote>
  <pre><code>def autoparts():
      parts_dict = {}
      list_of_parts = open('list_of_parts.txt', 'r')
      
      for line in list_of_parts:
          k, v = line.split()
          parts_dict[k] = v
  
      print(parts_dict)
  
  &gt;&gt;&gt; autoparts()
  {'part A': 1, 'part B': 2, ...}
  </code></pre>
  <p>This function creates a dictionary, but it does not return something.  However, since I added the <code>print</code>, the output of the function is shown when I run the function.  What is the difference between <code>return</code>ing something and <code>print</code>ing it?</p>