title: How can I simplifiy this python iteration?
body: <p>I want to get all possible combinations of three (or more) numbers. The numbers themselves need to be in the range of +-1. The range is to find 'similar numbers' - for example the number 3 needs to be iterated as 2,3,4. 
  E.g I have:</p>
  
  <pre><code>
      num1 = 3 
      num2 = 4
      num3 = 1
  
  </code></pre>
  
  <p>So in this example I want all combinations for these three numbers and every number +-1. (E.g. 341, 241, 441; 351, 331, ... ). So for the example numbers I should get 27 combinations.</p>
  
  <p>First idea was to use 3 for-loops in python like this:</p>
  
  <pre><code>
      num1 = 3
      num2 = 4
      num3 = 1
  
      def getSimilar(num1,num2,num3):
  
          num1 = n1 - 2
  
          for i in range (3):
              num1 = num1 + 1
              num2 = n2 - 2
  
              for j in range(3):
  
                  num2 = num2 + 1
                  num3 = n3 - 2
  
                  for k in range(3):
                      num3 = num3 + 1
                      print(num1,num2,num3)
  
  </code></pre>
  
  <p>Output I get:</p>
  
  <pre><code>
      2 3 0
      2 3 1
      2 3 2
      2 4 0
      2 4 1
      2 4 2
      2 5 0
      2 5 1
      2 5 2
      3 3 0
      3 3 1
      3 3 2
      3 4 0
      3 4 1
      3 4 2
      3 5 0
      3 5 1
      3 5 2
      4 3 0
      4 3 1
      4 3 2
      4 4 0
      4 4 1
      4 4 2
      4 5 0
      4 5 1
      4 5 2
  
  </code></pre>
  
  <p>Is there a smarter and faster way to do this in python instead of using 3 for loops? The order of the output does not matter.
  A small problem I additionally have: 
  If one number is 0, I need it to only iterate to 0 and 1, not to -1. 
  So the output for 0; 4; 1 should be:</p>
  
  <pre><code>
      0 4 1
      0 4 2
      0 4 0
  
      0 3 1
      0 3 2
      0 3 0
  
      0 5 1
      0 5 2
      0 5 0
  
      1 4 1
      1 4 2
      1 4 0
  
      1 3 1
      1 3 2
      1 3 0
  
      1 5 1
      1 5 2
      1 5 0
  
  </code></pre>