title: How to replace an object in python
body: <p>Given the following example code:</p>
  
  <pre><code>def myfunc(item):
    if item == 2:
      item = 1
  
  mylist = [1,2,3]
  for i in mylist:
    myfunc(i)
  print(mylist) # output is [1, 2, 3]
  # desired output is [1, 1, 3]
  </code></pre>
  
  <p>I would like to have a function that is called for some or all elements of a list. This function should be able to alter these elements.</p>
  
  <p>What would be the the cleanest solution for this problem?</p>