Complete the function that takes a non-negative integer `n` as input, and returns a list of all the powers of 2 with the exponent ranging from 0 to `n` (inclusive).

## Examples

```python
n = 0  ==> [1]        # [2^0]
n = 1  ==> [1, 2]     # [2^0, 2^1]
n = 2  ==> [1, 2, 4]  # [2^0, 2^1, 2^2]
```

Difficulty: introductory

Starter code:

def powers_of_two(n):
	

Solutions:
def powers_of_two(n):
    return [2**x for x in range(n+1)]

def powers_of_two(n):
    return [1<<x for x in range(n + 1)]

def powers_of_two(n): return [ 2 ** i for i in range(n+1) ]

def powers_of_two(n):
    a = []
    for i in range(0, n + 1):
        a.append(2 ** i)    
    return a

from itertools import accumulate, repeat, chain, islice
from operator import mul

gen, memo = accumulate(chain((1,), repeat(2)), mul), []

def powers_of_two(n):
    if len(memo) <= n:
        memo.extend(islice(gen, n-len(memo)+1))
    return memo[:n+1]

def powers_of_two(n):
    abc = []
    for i in range(0, n + 1):
        ghi = 2 ** i
        abc.append(ghi)
    return abc

def powers_of_two(n):
    arr = []
    for i in range(n + 1):
        arr.append(2 ** i)
    return arr

powers_of_two = lambda n: [ 2**i for i in range(0,n+1) ]

def powers_of_two(n):
    return list(map(lambda n: 2**n, [i for i in range(n+1)]))

def powers_of_two(n):
  #definelist
  return([2**x for x in range(0,n+1)])

from typing import List

def powers_of_two(n: int) -> List[int]:
    """ Return a list of all the powers of 2 with the exponent ranging from 0 to n. """
    return [2 ** _ for _ in range(n + 1)]

def powers_of_two(n):
    s=1
    a=[1]
    for i in range(n):
        s*=2
        a.append(s)
    return(a)

def powers_of_two(n):
    pL = [1]
    for i in range(n):
        pL.append(pL[i]*2)
    return pL

from itertools import count

def f():
    c = count()
    while True: yield 2 ** next(c)

def powers_of_two(n):
    iter = f()
    r = [next(iter) for x in range(n + 1)]
    return r

powers_of_two=lambda n:[1]if n==0 else powers_of_two(n-1)+[2**n]


def powers_of_two(n):
    if(n == 0):
        return [1]
    return powers_of_two(n-1) + [2**n]

def powers_of_two(n):
    a = []
    for i in range(n+1):
        a.append(2**i)
    return a

def powers_of_two(n):
    x = []
    
    while n > -1:
        y = 2 ** n
        x.append(y)
                
        n = n - 1
    
    return x[::-1]

def powers_of_two(n):
    a = 0
    arr = []
    while a <= n:
        arr.append(2 ** a)
        a += 1
    return arr

def powers_of_two(n):
    list_n = []
    i = 0
    while i != n + 1:
        list_n.append(2 ** i)
        i += 1   
    return list_n

def powers_of_two(n):
    return [2 ** l for l in range(n + 1)]

def powers_of_two(n):
    p = 1
    l = [ 1 ]
    for x in range(1, n+1):
        p *= 2;
        l.append(p)
    return l


def powers_of_two(n):
    s = []
    for el in range(0, n + 1):
        s.append(2**el)
    return s

def powers_of_two(n):
    arr = []
    for el in range(n+1):
        arr.append(2**el)
    return arr

def powers_of_two(N):
    return [2**n for n in range(N+1)]

def powers_of_two(n):
    emptylist = []
    for num in list(range(n+1)):
        x = 2**num
        emptylist.append(x)
    return emptylist

def powers_of_two(n):
    return [2**n for n in range(0+(n+1))]

from typing import List

def powers_of_two(n: int) -> List[int]:
    value = 1
    accu = [value]
    for i in range(n):
        value <<= 1
        accu.append(value)
    return accu

def powers_of_two(n):
    ll = []
    
    for i in range(n + 1):
        ll.append(2 ** i)
        
    return ll

def powers_of_two(n):
    arr = []
    for k in range(n+1):
        arr.append(2**k)
    return arr

def powers_of_two(n):
    result = [1]
    for i in range(1, n + 1):
        result.append(2**i)
        
    return result

def powers_of_two(n):
    i=0
    list=[1]
    for i in range(1,n+1):
        list += [2**i]
    return list

def powers_of_two(n):
    arr = list(range(n+1))
    return [2**el for el in arr]

def powers_of_two(n):
    return [2**x for x in range(n+1)]
    # returns an array of powers of two in the range from 0 to n


def powers_of_two(n):
    v=[];
    i=0;
    while i <= n:
        v.append(2**i);
        i+=1;
    return v;

def powers_of_two(n):
    if n == 0:
        return [1]
    else: 
        result = []
        for x in range(n+1):
            result.append(2**x)
        return result

def powers_of_two(n):
    i = 0
    s = 1
    array = []
    while i <= n:
        array.append(s)  
        i += 1
        s = (2 ** i)
    return array

def powers_of_two(n):
    lst=[2**n for n in range(n+1)]
    return lst

def powers_of_two(n):
    x = []
    for y in range(n+1):
        x.append(2**y)
    return x

def powers_of_two(n):
    a = []
    b = 1
    for i in range(0, n + 1):
        a.append(b)
        b = b * 2
    return a


def powers_of_two(n):
    a=2
    b=[]
    for i in range(n+1):
        b.append(2**i)
    return b

def powers_of_two(n):
    if n==0:
        return [1]
    num = 1
    my_list = [num]
    for i in range(1, (n+1)):
        num = num*2
        my_list.append(num)
    return my_list

def powers_of_two(n):
    new=[]
    for item in range(n+1):
        new.append(2**item)
    return new

def powers_of_two(n):
    emptylist = []
    for i in range(n+1):
        x = 2**i
        emptylist.append(x)
    return emptylist

def powers_of_two(n):
    return  [1] + [2**(x-1) for x in range(2,n+2)]

def powers_of_two(n):
    ls=[]
    i=0
    while i<=n:
        ls.append(2**i)
        i=i+1
    return ls

def powers_of_two(n):
    return list(map(lambda y: 2**y , range(n+1)))

def powers_of_two(n):
    new_list = list(range(0, n+1))
    return [ 2 ** x for x in new_list ]

def powers_of_two(n):
    l = list()
    for i in range(n+1):
        l.append(2**i)
    return l

import unittest


def powers_of_two(n):

    return [2 ** i for i in range(n + 1)]
    
    
class TestPowerOfTwo(unittest.TestCase):
    def test_power_of_two(self):
        n = 4
        actual = power_of_two(n)
        self.assertEqual(actual, [1, 2, 4, 8, 16])


def powers_of_two(n):
    result = []
    a = 0
    while a < n+1:
        b=2**a
        result.append(b)
        a = a+1
    return result

def powers_of_two(n):
    lst = []
    x = 0
         
    for i in range(0, n + 1):
            x = 2 ** i
            lst.append(x)
    return lst

def powers_of_two(n):
    power = n
    square_list = [1]
    for i in range(1,n+1):
        square_list.append(2 ** i)
    return square_list

def powers_of_two(n):
    
    final = []
    for i in range(n+1):
        final.append(2**i)
    return final
    


def powers_of_two(n):
    return [2 ** el for el in range(n + 1)]

def powers_of_two(n):
    result = []
    i = 0
    while i < n+1:
        num = 2 ** i
        i += 1
        result.append(num)
    return result

def powers_of_two(n):
    powof2 = []
    num = 1
    for i in range(n+1):
        powof2.append(num)
        num *= 2
    return powof2

def powers_of_two(n):
    newN = []
    num = 0
    while num <= n:
        newN.append(2**num)
        num += 1
    return newN

def powers_of_two(n):
    newN = []
    num = 0
    while num <= n:
        newN += [2**num]
        num += 1
    return newN

def powers_of_two(n):
    result = []
    
    for i in range(n + 1):
        result.append(2 ** i)
        
    return result
    
# powers_of_two = lambda n: list(map(lambda i: 2 ** i, list(range(n + 1))));


def powers_of_two(n):
    tab=[]
    for x in range(n+1):
        a=2**x
        tab.append(a)
    return tab

def powers_of_two(n):
    new_arr = []
    for i in range(n+1):
        new_arr.append(2 ** i)
    return new_arr

def powers_of_two(n):
    return [2 ** power for power in range(0, n + 1)]

def powers_of_two(n):
    a=[]
    for i in range(n+1):
        b=2**i
        a.append(b)
    return a

def powers_of_two(n):
    return list(2**num for num in list(range(0, n+1)))

def powers_of_two(n):
    output = []
    for i in range(0,n+1):
        output.append(2**i)
    return output

def powers_of_two(n):
    return [pow(2, exp) for exp in range(n + 1)]

def powers_of_two(n):
    if n == 0 : return [1]
    accum_array = []
    for i in range(n+1):
        if (i == 0):
            accum_array.append(i+1)
        else:
            accum_array.append(accum_array[-1] * 2)
    return accum_array

def powers_of_two(n):
    lst=[2**i for i in range(0,n+1)]
    return lst

powers_of_two = lambda n: [1 << k for k in range(n + 1)]

from math import pow

def powers_of_two(n):
    nums = []
    for exp in range(0, n+1):
       nums.append(int(pow(2, exp)))
    return nums


def powers_of_two(n):
    return list(map(lambda x: 2**(x-1), list(range(1, n+2))))

def powers_of_two(n):
    l = []
    i = 0
    while i <= n:
        l.append(2**i)
        if i <=n:
            i += 1
    return l

def powers_of_two(n):
    x = 0
    ans =[]
    while x <= n:  
        a=2**x 
        x+=1
        ans.append(a)
    return ans
    
    
    
    
    
    #n = n ** 2 
    #return range [ x , n, n **2 ]


def powers_of_two(n):
    array1 = []
    for i in range(n + 1):
        array1.append(2 ** i)
    return array1

def powers_of_two(n):
    x = [1]
    if n == 0:
        return x
    else:
          for i in range(1,n+1):
              x.append(2**i)
    return x

def powers_of_two(n):  
    power = 2 
    doubler = [1] 
    while n > 0:
        doubler.append(power) 
        n -= 1 
        power *= 2 
    return doubler

def powers_of_two(n):
    a = [1]
    if n == 0:
        return a
    else:
        for i in range(1,n+1):
            a.append(2**i)  
    return a

def powers_of_two(n):
    num1 = 0
    list = []
    for x in range(n+1):
        list.append(pow(2,x))
    return list

def powers_of_two(n):
    return [2**i for i in list(range(0,n+1))]
        
 


def powers_of_two(n):
    numbers=[]
    i = 0
    for i in range(0, n+1):
       numbers.append(2**i)
       if i == n:
            return(numbers)

def powers_of_two(n):
  num = n
  twopower = 2
  doubles = [1]

  while num > 0:
    doubles.append(twopower)
    num -= 1
    twopower *= 2

  return doubles

def powers_of_two(n):
    num = []
    for i in range(0, n + 1):
        num.append(2 ** i)    
    return num

def powers_of_two(n):
    last_list=[]
    for i in range(n+1):
        last_list.append(2**i)
    return last_list

from math import pow

def powers_of_two(n):
    return [pow(2, i-1) for i in list(range(1, n+2))]

def powers_of_two(n):
    lst = []
    for i in range(0,n+1):
        lst.append(i)
    return list(map(lambda x: 2**x, lst))

def powers_of_two(n):
    return [2**value for value in range(n+1)]

def powers_of_two(n):
    x=[]
    for i in range(0,n+1):
        x.append(2**i)
        
    return x

import math
def powers_of_two(n):
    rez = []
    i = 0
    while i <= n :
        rez.append(math.pow(2,i))
        i += 1
        
    return rez

def powers_of_two(n):
    new_n = []
    for i in range(n+1):
        new_n.append( 2**i )
    return new_n

def powers_of_two(n):
    lst = [];
    for num in range(0,n+1):
      lst.append(2 ** num);
    return lst;


def powers_of_two(n):
    p = 0 
    ans = []
    while p <= n: 
        i = 2**p 
        p += 1 
        ans.append(i)
    return ans 

def powers_of_two(n):
    return [2 ** i if i != 0 else 1 for i in range(0, n+1)]

def powers_of_two(n):
    d,a=[],1
    for i in range(n+1):
        d.append(a)
        a*=2
    return d

def powers_of_two(n):
    power=[]
    for i in range(0,n+1):
      power.append(2**i)
    return power


def powers_of_two(n):
    array = []
    for i in range(0,n+1):
        print(2 ** i)
        array.append(2 ** i)
    return array

def powers_of_two(maxi):
    return [2 ** n for n in range(maxi + 1)]

def powers_of_two(n: int):
    return  [ 2**i for i in range(0, n + 1)]