+ 1
Where am I going wrong with the average
8 Answers
+ 4
wrong:
for height in heights:
h += height
count +=1
average = height / count
right:
for height in heights:
h += height
count +=1
average = h / count
+ 2
You're calculating it wrong, you use the last height-value and divide it by the number of heights instead of dividing the sum of all heights.
+ 2
I just noticed that thank you for your help and patience with me I thought I had that variable in there properly so I thought it was my implementation of the math in python
+ 1
Did you run the code or just read it the height value being used is the sum of the heights
+ 1
This is my first app that itterates through an array
0
No for an actual average your supposed to take the sum and divide by the number
0
Yes and this is exactly what you're NOT doing... As I wrote...
0
This is the first time I've down voted my comment to highlight the help I was given and that's cause I'm sure there are hundreds out there making that same mistake