I need to create a code using list comprehension that looks at a predetermined list X = [5,6,7] and creates a new list that includes a list of the powers of X, the powers being from 0 to k. I was able to write the code that could create the powers of X however when I run my code instead of receiving the desired output:
[[1, 5, 25], [1, 6, 36], [1, 7, 49]]
I receive this: [[1, 5, 25, 1, 6, 36, 1, 7, 49]]
Here is the code I am running,
[[i**j for i in X for j in range(k+1)]]
I've tried fiddling with the bracket placement but when I change the brackets to contain only [i**j] the results become even more peculiar:
[[1], [5], [25], [1], [6], [36], [1], [7], [49]]
Any help or advice would be greatly appreciated!