title: Should I ever return a list that was passed by reference and modified?
body: <p>I have recently discovered that lists in python are automatically passed by reference (unless the notation array[:] is used). For example, these two functions do the same thing:</p>
  
  <pre><code>def foo(z):
      z.append(3)
  
  def bar(z):
      z.append(3)
      return z
  
  x = [1, 2]
  y = [1, 2]
  foo(x)
  bar(y)
  print(x, y)
  </code></pre>
  
  <p>Before now, I always returned arrays that I manipulated, because I thought I had to. Now, I understand it's superfluous (and perhaps inefficient), but it seems like returning values is generally good practice for code readability. My question is, are there any issues for doing either of these methods/ what are the best practices? Is there a third option that I am missing? I'm sorry if this has been asked before but I couldn't find anything that really answers my question.</p>