title: python - getting 'none' at the end of printing a list
body: <p>newbie here. can someone please explain to me why 'none' is printed at the end of this code, but only when called inside a function?</p>
  
  <p>background:
  I have a variable (share_data) which contains some lists:</p>
  
  <pre><code>share_data = 
  [['Date', 'Ticker', 'Company', 'Mkt Cap', 'VM Rank', 'Value Rank', 'Momentum Rank'],  
  ['2016-08-27', 'BEZ', 'Beazley', '2,063', '89', '72', '76'], 
  ['2016-08-30', 'BEZ', 'Beazley', '2,063', '89', '72', '76'], 
  ['2016-08-31', 'BEZ', 'Beazley', '2,050', '89', '72', '75'], 
  ['2016-09-01', 'BEZ', 'Beazley', '2,039', '96', '73', '93'], 
  ['2016-09-02', 'BEZ', 'Beazley', '2,069', '90', '72', '77'], 
  ['2016-09-03', 'BEZ', 'Beazley', '2,120', '96', '70', '94'], 
  ['2016-09-06', 'BEZ', 'Beazley', '2,106', '90', '71', '77'], 
  ['2016-09-07', 'BEZ', 'Beazley', '2,085', '89', '71', '76'], 
  ['2016-09-08', 'BEZ', 'Beazley', '2,091', '89', '72', '77'], 
  ['2016-09-09', 'BEZ', 'Beazley', '2,114', '89', '71', '77'], 
  ['2016-09-10', 'BEZ', 'Beazley', '2,084', '94', '71', '89'], 
  ['2016-09-12', 'BEZ', 'Beazley', '2,084', '94', '71', '89']]
  </code></pre>
  
  <p>I am interested in printing the last 5 lines.</p>
  
  <p>If I use this in the <em>main</em> program:</p>
  
  <pre><code>for row in share_data[-5:]:
      print(row)
  </code></pre>
  
  <p>I get the correct data:</p>
  
  <pre><code>['2016-09-07', 'BEZ', 'Beazley', '2,085', '89', '71', '76']
  ['2016-09-08', 'BEZ', 'Beazley', '2,091', '89', '72', '77']
  ['2016-09-09', 'BEZ', 'Beazley', '2,114', '89', '71', '77']
  ['2016-09-10', 'BEZ', 'Beazley', '2,084', '94', '71', '89']
  ['2016-09-12', 'BEZ', 'Beazley', '2,084', '94', '71', '89']
  </code></pre>
  
  <p>...however when I created a function to do this:</p>
  
  <pre><code>def share_details(share_data, n=5):
      ''' Prints the last n rows of a share's records'''
      for row in share_data[-n:]:
          print(row)
      return
  </code></pre>
  
  <p>and called the function this way:</p>
  
  <pre><code>print(share_details(share_data))
  </code></pre>
  
  <p>...what I get is this (note the 'None' at the end):</p>
  
  <pre><code>['2016-09-07', 'BEZ', 'Beazley', '2,085', '89', '71', '76']
  ['2016-09-08', 'BEZ', 'Beazley', '2,091', '89', '72', '77']
  ['2016-09-09', 'BEZ', 'Beazley', '2,114', '89', '71', '77']
  ['2016-09-10', 'BEZ', 'Beazley', '2,084', '94', '71', '89']
  ['2016-09-12', 'BEZ', 'Beazley', '2,084', '94', '71', '89']
  None
  </code></pre>
  
  <p>I think it's the 'return' statement at the end of the function that triggers it, but don't know how/why.</p>
  
  <p>EDIT - now that's it's clear what my error was (ie. printing <em>inside</em> the function, and then also the return value outside) can I follow up with an additional question? 
  <strong>Is it good practice to delegate all the printing to a function?</strong> Maybe a function called, for extra readability:</p>
  
  <pre><code>print_share_details(share_data)
  </code></pre>
  
  <p>Or there is a better way which is more readable/pythonic?</p>