# Its ok to be average

#1

this is the code i wrote to retrieve the averages and the error i get is as follows:

error: Oops, try again. average([3, 0]) returned 3 instead of 1.5 as expected.

def average(numbers):
total = sum(numbers)
float(total)
total / len(numbers)

I think I have the indentations correct they're just not showing in the post, any help would be much appreciated.

#2

Because the code that you posted is not formatted, it is difficult for other users to read and debug it. After code has been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. Alternatively, you can place three backquotes on the line before the code and three backquotes on the line after the code. This will enable us to see important details, such as the indentation and underscores. If you use the backquotes, your code will be color-coded, making it especially easy to read.

These two statements do not actually change the value of `total` ...

``````float(total)
total / len(numbers)``````

To convert `total` to a `float` and assign that converted value to `total`, you can do this ...

``total = float(total)``

Then, to divide `total` by `len(numbers)` and assign the result of the division to `total`, do this ...

``total = total / len(numbers)``

... or this ...

``total /= len(numbers)``

#3

appylye,

thank you very much for the advice it was useful and got me through the lesson.

#4

@appylpye
Thank you as well, it got me through that lesson too.

#7