Hello I have a simple problem here, I wanted to make a function that will compute the average (adding the numbers and dividing it by the count). my functions seems to display the wrong result, can you help me put comments on my source code what I did wrong and explain please? Thank you so much for you time.
#average1.py
def main():
n = input("How many numbers do you have?")
sum = 0.0
for i in range(n):
x = input("Enter a number: ")
sum = sum + x
print "\n The average of the number is ", sum/n
--------------------------------------------------------
Example: This is the result when I call the function main()
--------------------------------------------------------
How many numbers do you have?5
Enter a number: 1
The average of the number is 0.2
Enter a number: 2
The average of the number is 0.6
Enter a number: 3
The average of the number is 1.2
Enter a number: 4
The average of the number is 2.0
Enter a number: 5
The average of the number is 3.0
---------------------------------------------------------
I want the the print ---> "\n The average of the number is ", sum/n <---- to appear only once.

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this

and **thousands** of other questions.

- anonymous

- jamiebookeater

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your **free** account and access **expert** answers to this

and **thousands** of other questions

- anonymous

http://pastebin.com/5nrSEteB
looks like it works to me

- anonymous

But I want the the print ---> "\n The average of the number is ", sum/n <---- to appear only once.

- anonymous

ahhh - move it outside of the for loop

Looking for something else?

Not the answer you are looking for? Search for more explanations.

## More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.