title: Python List Comprehensions Create a List of Powers Understanding the Programming
body: <p>So the question is from</p>
  <p><a href="https://github.com/Asabeneh/30-Days-Of-Python/blob/master/13_Day_List_comprehension/13_list_comprehension.md" rel="nofollow noreferrer">https://github.com/Asabeneh/30-Days-Of-Python/blob/master/13_Day_List_comprehension/13_list_comprehension.md</a></p>
  <p>Using list comprehension create the following list of tuples:</p>
  <pre><code>[(0, 1, 0, 0, 0, 0, 0),
  (1, 1, 1, 1, 1, 1, 1),
  (2, 1, 2, 4, 8, 16, 32),
  (3, 1, 3, 9, 27, 81, 243),
  (4, 1, 4, 16, 64, 256, 1024),
  (5, 1, 5, 25, 125, 625, 3125),
  (6, 1, 6, 36, 216, 1296, 7776),
  (7, 1, 7, 49, 343, 2401, 16807),
  (8, 1, 8, 64, 512, 4096, 32768),
  (9, 1, 9, 81, 729, 6561, 59049),
  (10, 1, 10, 100, 1000, 10000, 100000)]
  </code></pre>
  <p>The following is my solution:</p>
  <pre class="lang-py prettyprint-override"><code>powers_list = [tuple([i] + [i**j for j in range(6)]) for i in range(11)]
  print(powers_list)
  </code></pre>
  <p>This next part I got form GeeksForGeeks:</p>
  <pre class="lang-py prettyprint-override"><code>
  matrix = []
    
  for i in range(11):
      # Append an empty sublist inside the list
      matrix.append([i])
  
      for j in range(6):
          matrix[i].append(i**j)
  print(matrix)
  </code></pre>
  <p>I understand the geeks for geeks part. However, the list comprehension is confusing to me. Why and How does</p>
  <pre><code>[i] + [i**j..]]
  </code></pre>
  <p><code>[i]</code> append/prepend to the list instead of resulting in <code>[[0], [1, 0, 0, 0, 0]]</code>?</p>
  <p>Does the <code>+</code> function as <code>listA.extend(listB)</code>?</p>