Create a Python program to generate the powers of two up to a given number.
8
def powersOfTwo(n):
    powers = []
    for i in range(n + 1):
        powers.append(2**i)
    return powers

n = 8
print(powersOfTwo(n))