title: Python deep reverse in a list
body: <p>I have a nested list, and I need to reverse every element in the list. But I dont know whether the list is a list of list of list or not.
  So example is:</p>
  
  <pre><code>p = [1, [2, 3, [4, [5, 6]]]]
  print deep_reverse(p)
  #&gt;&gt;&gt; [[[[6, 5], 4], 3, 2], 1]
  
  q =  [1, [2,3], 4, [5,6]]
  print deep_reverse(q)
  #&gt;&gt;&gt; [ [6,5], 4, [3, 2], 1]
  </code></pre>
  
  <p>What I have so far is:</p>
  
  <pre><code>def is_list(p):
      return isinstance(p, list)
  
  def deep_reverse(a):
      a.reverse()
      for i in a:
          if is_list(i):
              i.reverse()
              print a
  </code></pre>
  
  <p>It works well for the second test, the q one, but doest work for the first test.
  I am not sure do I need use a recursion to loop the whole thing? How can I modify my code? Thanks.</p>