Sunday , January 24 2021

How to find the average value of a list in python

To answer the question of:

Please help me understand the problems in my code

The problem is the lines

to count the votes
if the count> = 50:
average = sum (count) / len (count)

vote it's a list of integers. So, when you loop to count the votes, the value of to count it's an integer I've tested your code in both Python 3.6.3 and 2.7.10 and you can not even call it sum() is len () it works on an integer (both return to TypeError if you try).

It initializes average = []so you seem to expect average to contain a list, but also if sum (count) = count is len (count) = 1, then average contains an integer, not a list.

I'd be curious to know which version of Python you're using that allows this code to run without errors.

Corrections for these errors have already been provided.

Source link


  1. hyundai replacement key

    Wohh just what I was searching for, appreciate it for posting. I love your website!

  2. tadalafil tablets

    I am also commenting to let you know of the helpful encounter my friend’s daughter found reading through your web page. She figured out numerous issues, not to mention what it’s like to have an amazing giving mood to have most people really easily know selected impossible subject areas. You really exceeded our own expectations. Many thanks for imparting the invaluable, safe, explanatory and even easy thoughts on the topic to Janet.

  3. I enjoy you because of all your efforts on this site. Ellie enjoys doing internet research and it’s easy to see why. All of us hear all concerning the compelling means you deliver good information by means of the blog and as well cause contribution from other people about this concept plus my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a dazzling job.

  4. I am just writing to make you understand what a really good experience my wife’s princess obtained using your webblog. She noticed some things, which included what it is like to possess an excellent teaching spirit to make others with no trouble learn about specific tortuous things. You undoubtedly surpassed readers’ expected results. Thanks for providing those productive, trusted, informative as well as unique tips on your topic to Mary.

Leave a Reply

Your email address will not be published.