def problem(n): myList = [] for j in range(0, n): number = 2 ** j myList.append(number) return myList
I want this code to return the powers
As @JBernardo pointed out, I assume there is a typo in your question.
def squares(n): power = n square_list = [] for i in range(1,n+1): square_list.append(2 ** i) return square_list print squares(4)
will return
[2,4,8,16]