title: copy variable by value not reference
body: <p>quite new to python and struggling to achieve a value copy of a variable. have an algorithm that calls recursively another one but not getting the desired values since i think im instead using reference when assigning one variable to another in the following code:</p>
  <pre><code>def search(problem, strategy, depthl, depthi, pruning):
      depthact = depthi
      sol = None
      while(not sol and depthact &lt;= depthl):
          sol = limSearch(problem, strategy, depthact, pruning)
          depthact += depthi
      return sol
  </code></pre>
  <p>i want to have in <strong>depthact</strong> the same value as <strong>depthi</strong> but instead i think im pointing to the same memory location and therefore when calling <em>limSearch</em> im doing it with whatever value is passed to the method in <em>depthi</em> instead of the other one that is the one i wanna use since i then increment it.</p>
  <p>am i right? any help will be much appreciated.</p>
  <p><strong>edit:</strong> i know the solution to the limSearch algoritm is in a depth=35 but want this other algorithm to check if a solution exits for a given depth increment so, if i call search with depthl=40 and a depthi of 2, it should run limSearch passing in depthact the value 2 at first, then 4, 6, 8, 10.. until it reaches 36 that then it should find the solution cause of it being in 35 but it does not work, instead im getting a sol=None in all cases as if i was calling limSearch with other values.</p>
  <blockquote>
  <p>def search(problem, strategy, 40, 2, pruning):</p>
  </blockquote>
  <p>i want a call like this one to be in the loop calling limSearch until it reaches a solution in that algorithm that in this case is in depth=35. so my expected result is:</p>
  <blockquote>
  <p>sol = limSearch(problem, strategy, 2, pruning)</p>
  <p>sol = limSearch(problem, strategy, 4, pruning)</p>
  <p>sol = limSearch(problem, strategy, 6, pruning)</p>
  </blockquote>
  <p>...</p>
  <blockquote>
  <p>sol = limSearch(problem, strategy, 36, pruning)</p>
  </blockquote>
  <p>in this last iteration sol will not be none and then the while loop will no longer be executed returning me the desired solution.</p>
  <p>the context where i call this function is the following:</p>
  <pre><code>if(strategy == 3): sol = search(p, strategy, depthl, depthi, pruning)
  else: sol = limSearch(p, strategy, depthl, pruning)
  </code></pre>
  <p>after reading all the values values by user inputs.</p>
  <pre><code>depthl = int(input('depth: '))-1
  if(strategy == 3): depthi = int(input('depth increment: '))
  </code></pre>