Question: I was given an assignment to find the sum of the squares of the first n odd numbers whereby n is given by the user.

The assignment was;

```
The script only takes one input, so do not
# include any input command below. The print commands below are already given.
# Do not alter the print commands. Do not add any other prints commands.

r = range(1, n + 1)         # prepare the range
result = 0                  # initialise the result
for k in r:                 # iterate over the range
    result = result + k     # update the result

  compute the sum of the squares of the first n odd numbers, and print it

```

This is what I have done so far;

```
r = range(1, n ** n, 2)         
result = 0                  
for k in r:                 
    result = result + k     

```

I know the range is wrong because when I ran it, I used 5 as n and I expected the answer to be 165 because the squares of the first 5 odd numbers is 165 but instead I got 144.

Please help

Answer: 
We want to do iterate through odd numbers so if we want to do n odd numbers we need to go up to 2\*n. For example, 5 odd numbers would be 1,3,5,7,9 and 2\*5=10, but we only want every other number so we have the command `r = range(1, n * 2, 2)`

We then start with zero and add to it, hence `result = 0`

Now we iterate through our range (r) and add to our result the iterator squared, hence `result = result = (k * k)`

Overall we have:

```
r = range(1, n * 2, 2)
result = 0
for k in r:
    result = result + (k * k)
print result

```
`n**n` is n to the nth power. So with `n=5`, your range is all the odd numbers between 1 and 3125. It should be odd numbers between 1 and 10.

```
r = range(1, n ** n, 2) 
#               ^ replace n**n by ...

```

You want to sum squares, so you should compute squares :

```
result = result + k
#                   ^ something is missing here

```