Where am I going wrong with the average | Sololearn: Learn to code for FREE!
3rd Jun 2020, 1:12 AM
Joshua Flynn
Joshua Flynn - avatar
8 odpowiedzi
+ 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
3rd Jun 2020, 2:03 AM
Sandra Meyer
Sandra Meyer - avatar
+ 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.
3rd Jun 2020, 1:21 AM
Sandra Meyer
Sandra Meyer - avatar
+ 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
3rd Jun 2020, 2:05 AM
Joshua Flynn
Joshua Flynn - avatar
+ 1
Did you run the code or just read it the height value being used is the sum of the heights
3rd Jun 2020, 2:02 AM
Joshua Flynn
Joshua Flynn - avatar
+ 1
This is my first app that itterates through an array
3rd Jun 2020, 2:10 AM
Joshua Flynn
Joshua Flynn - avatar
0
No for an actual average your supposed to take the sum and divide by the number
3rd Jun 2020, 2:00 AM
Joshua Flynn
Joshua Flynn - avatar
0
Yes and this is exactly what you're NOT doing... As I wrote...
3rd Jun 2020, 2:01 AM
Sandra Meyer
Sandra Meyer - avatar
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
3rd Jun 2020, 2:08 AM
Joshua Flynn
Joshua Flynn - avatar